1.下載YUM庫
shell > wget http://dev.MySQL.com/get/mysql57-community-release-el7-7.noarch.rpm
2.安裝YUM庫
shell > yum localinstall -y mysql57-community-release-el7-7.noarch.rpm
3.安裝數據庫
shell > yum install -y mysql-community-server
4.啟動MySQL服務
shell > systemctl start mysqld.service
5.默認空密碼
shell > mysql -uroot -p
輸入密碼后提示:ERROR 1045 (28000): access denied for user 'root'@'localhost' (using passWord: NO)6.開啟mysql安全模式(重要!這里跟百度出來其他開啟安全模式方法不一樣)
修改my.cnf,添加skip-grant-tables和skip-networking
輸入:vi /etc/my.cnf
[mysqld]
skip-grant-tables
skip-networking
重啟mysql 然后輸入: mysql -uroot mysql 此時即可登錄mysql
然后:update mysql.user set authentication_string=password("root123") where user="root" and Host="localhost";
flush PRivileges;
quit;
重啟mysql后添加遠程登錄用戶(登入Mysql):
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root123' WITH GRANT OPTION;
此時提示:The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
意思是要修改密碼,原來忘記修改my.cnf 退出安全模式
輸入:vi /etc/my.cnf 刪除
skip-grant-tables
skip-networking
修改密碼時 如遇到提示: You must reset your password using ALTER USER statement before executing this statement.執行下列操作:set global validate_password_policy=0;
set global validate_password_mixed_case_count=0;
set global validate_password_number_count=3;
set global validate_password_special_char_count=0;set global validate_password_length=3;
然后更改密碼即可
新聞熱點
疑難解答