標籤:mysql centos7
參考了下面兩個連結
http://www.centoscn.com/mysql/2016/0315/6844.html 連結A
http://www.cnblogs.com/starof/p/4680083.html 連結B
centos7不再預設安裝mysql,預設安裝的是mariadb,在命令列裡輸入yum install mysql可以看到提示中顯示要下載mariadb.
mariadb的安裝可以參數連結B中的描述
下面是從連結A中擷取的安裝mysql方法.
在/etc/yum.repos.d目錄中添加一個檔案mysql-community.repo,檔案內容為
#Enble to use MySQL 5.6[mysql56-community]name=MySQL 5.6 Community Serverbaseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/enabled=1gpgcheck=0gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
在命令列中輸入,yum install mysql-community-server,即可以安裝mysql,安裝的是mysql5.6,如果系統中安裝了mariadb,mysql的安裝還會將mariadb刪除.
安裝過程中還遇到了一個問題
無法安裝mysql-InvalidGPGKeyfromfile:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
這裡參考了
http://www.2cto.com/database/201701/586216.html
即將檔案/etc/yum.repos.d/mysql-community.repo中的gpgcheck=1改成gpgcheck=0即可.
這是為什麼上面的檔案與連結A中的檔案內容不同的原因.
啟動mysql
systemctl start mysqld.service
初次安裝mysql是root賬戶是沒有密碼,需要設定一下,
mysql -h localhost -u root -p進入mysql
設定密碼的時候遇到了問題
mysql> set password for ‘root’@‘localhost’ = password(‘123456‘);ERROR 1133 (42000): Can‘t find any matching row in the user table
解決方案
mysql> grant all on mysql.user to ‘root‘@‘%‘ identified by ‘password‘;Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)mysql> update mysql.user set password=password(‘123456‘) where user =‘root‘;Query OK, 5 rows affected (0.00 sec)Rows matched: 5 Changed: 5 Warnings: 0mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)
本文出自 “夢裡不知身是客” 部落格,請務必保留此出處http://tenfee.blog.51cto.com/6353835/1915007
centos7 安裝 mysql