雖然是根據(jù)老徐的那篇(軟件測試從業(yè)者必備之MYSQL從零到入坑)來安裝肆饶,但是實際操作過程中還是遇到各種問題类少,最后還參考了其他文章(eg.http://www.linuxidc.com/Linux/2016-09/135288.htm)才算完全入坑成功瘾英。下面主要列一下我的安裝過程顿天,以做記錄犀忱。
1.檢查自帶版本數(shù)據(jù)庫
[root@bogon ~]$ yum list installed |grep sql
注:我的系統(tǒng)是centos7.0拣展,這里自帶的數(shù)據(jù)庫是sqlite,為了不安裝那么多梭灿,我把它也刪掉
2.刪除自帶版本
[root@bogon ~]$ yum -y remove sqlite
3.下載并安裝mysql 的rpm源
[root@bogon tools]$?wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm?--no-check-certificate
[root@bogon tools]$?yum localinstall mysql57-community-release-el7-8.noarch.rpm
4.驗證本地mysql yum源是否安裝成功
[root@bogon ~]$ ?yum repolist all |grep mysql
mysql-connectors-community MySQL Connectors Community enabled: 42
mysql-connectors-community-source MySQL Connectors Community - So disabled
mysql-tools-community? ? ? ? ? ? MySQL Tools Community? ? ? ? ? enabled:? ? 55
mysql-tools-community-source? ? ? MySQL Tools Community - Source? disabled
mysql-tools-preview? ? ? ? ? ? ? MySQL Tools Preview? ? ? ? ? ? disabled
mysql-tools-preview-source? ? ? ? MySQL Tools Preview - Source? ? disabled
mysql55-community? ? ? ? ? ? ? ? MySQL 5.5 Community Server? ? ? disabled
mysql55-community-source? ? ? ? ? MySQL 5.5 Community Server - So disabled
mysql56-community? ? ? ? ? ? ? ? MySQL 5.6 Community Server? ? ? disabled
mysql56-community-source? ? ? ? ? MySQL 5.6 Community Server - So disabled
mysql57-community? ? ? ? ? ? ? ? MySQL 5.7 Community Server? ? ? enabled:? 247
mysql57-community-source? ? ? ? ? MySQL 5.7 Community Server - So disabled
5.安裝mysql
[root@bogon ~]$ ?yum install mysql-community-server
6.啟動mysql
[root@bogon ~]$ systemctl start mysqld
查看mysql狀態(tài)
[root@bogon ~]$?systemctl status mysqld
7.開機自啟動
[root@bogon ~]$?systemctl enable mysql
[root@bogon ~]$?systemctl?daemon-reload
至此mysql安裝成功画侣,下面進行登錄以及遠程訪問
8.登錄mysql
[root@bogon ~]# mysql -uroot -p
Enter password:
或者:[root@bogon ~]#?grep 'temporary password' /var/log/mysqld.log
注:這里直接回車后或者通過查看臨時密碼并輸入臨時密碼后仍提示錯誤:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
解決方法http://blog.csdn.net/myth_xgx/article/details/50809645:
??$ sudo systemctl stop mysqld.service
? ? ?$ sudo?systemctl set-environment MYSQLD_OPTS="--user=mysql --skip-grant-tables --skip-networking"
? ? ?$?sudo systemctl start mysqld.service? ??
? ? ?$?mysql -u root mysql
? ? ?mysql > UPDATE mysql.user SET authentication_string=PASSWORD("abcdef")? WHERE user='root' and host='localhost';
? ? ?mysql >?flush privileges;
? ? ?mysql > quit
? ? ?$ sudo?systemctl unset-environment MYSQLD_OPTS
? ? ?$?sudo systemctl restart mysqld.service
然后再進入mysql并修改密碼
[root@bogon ~]# ?mysql -uroot -p
Enter password:abcdef
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass11!';
之后密碼為修改后的密碼。
9堡妒,遠程連接
mysql> GRANT ALL PRIVILEGES ON *.* TO 'emmalong'@'%' IDENTIFIED BY 'MyNewPass11!'?
mysql> FLUSH PRIVILEGES;
mysql> EXIT;