linux下配置mysql_linux下安装mysql
1.1.?檢測是否已經安裝了mysql
rpm -qa | grep mysql
如果已經安裝了,將其卸載,如:
rpm -e --nodeps ?mysql-libs-5.1.71-1.el6.x86_64
1.2.?安裝mysql
1、mkdir /usr/local/src/mysql
2、cd /usr/local/src/mysql
3、tar -xvf MySQL-5.6.22-1.el6.i686.rpm-bundle.tar(解壓)
4、安裝server
rpm -ivh MySQL-server-5.6.22-1.el6.i686.rpm
出錯:
安裝依賴:yum -y install libaio.so.1 libgcc_s.so.1 libstdc++.so.6
需要升級libstdc++-4.4.7-4.el6.x86_64
yum ?update libstdc++-4.4.7-4.el6.x86_64
5、安裝中:
6、安裝client
安裝依賴:yum?-y install libncurses.so.5 libtinfo.so.5
7、查詢mysq服務運行狀態
服務未啟動。
8、?啟動mysql服務
service mysql start
9、使用root賬號登錄mysql
提示:
在安裝mysql?server時有句提示:
1、?注意:這個密碼是不安全的,所有需要修改初始密碼。
2、?使用密碼登錄mysql賬號:mysql -uroot -p
3、?修改root密碼:SET PASSWORD = PASSWORD('123456');
2.3?系統啟動時自動啟動mysql服務
注意:
centos7開始使得以往老版本系統服務的/etc/init.d的啟動腳本的方式就此改變,在centos7中所有對服務的管理都集中到了systemctl當中。
systemctl是一個系統管理守護進程、工具和庫的集合,用于取代以往的System V、service和chkconfig命令。
創建用于啟動MySQL的配置文件
[root@localhost ~]# touch /usr/lib/systemd/system/mysqld.service
[root@localhost ~]# cd /usr/lib/systemd/system
編輯mysqld.service文件,加入如下內容:
[root@localhost system]# vi mysqld.service
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/opt/mysql-5.7.18/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 5000
保存退出
備注:ExecStart=/opt/mysql-5.7.18/bin/mysqld (此處請對應修改為MySQL程序所在的路徑)
查找mysqld路徑,例如:
[root@localhost system]# which mysqld
/opt/mysql-5.7.18/bin/mysqld
通過systemctl方式啟動mysql5.7:
[root@localhost system]# systemctl start mysqld
檢查MySQL運行狀態:
[root@localhost system]# mysql -p
Enter password:
Welcome to the MySQL monitor. ?Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.18-log MySQL Community Server (GPL)
關閉防火墻:
[root@localhost system]# systemctl stop firewalld.service
[root@localhost system]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
設置mysql的開機啟動:
[root@localhost system]# systemctl enable mysqld
Created symlink from /etc/systemd/system/multi-user.target.wants/mysqld.service to /usr/lib/systemd/system/mysqld.service.
[root@localhost system]# systemctl list-unit-files | grep mysqld
mysqld.service ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?enabled
取消mysql的開機自啟動:
[root@localhost system]# systemctl disable mysqld
Removed symlink /etc/systemd/system/multi-user.target.wants/mysqld.service.
[root@localhost system]# systemctl list-unit-files | grep mysqld
mysqld.service ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?disabled
總結
以上是生活随笔為你收集整理的linux下配置mysql_linux下安装mysql的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 咸鱼笔记—认识电商
- 下一篇: 智能分析网关微信端告警消息推送的开发流程