出現報錯:
Warning: World-writable config file '/etc/my.cnf' is ignored // 該文件權限過高
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)// 密碼錯誤
解決方法:
1. chmod 644 /etc/my.cnf // 修改/etc/my.cnf權限
2. grep 'password' /var/log/mysqld.log |head -n 1 // 找臨時密碼,如果找不到請看3
3. 3如果不行請看4
1.刪除原來安裝過的mysql殘留的數據(這一步非常重要,問題就出在這) rm -rf /var/lib/mysql 2.重啟mysqld服務 systemctl restart mysqld 3.再去找臨時密碼 grep 'temporary password' /var/log/mysqld.log
4. #重置密碼
(1) 在[mysqld]后面任意一行添加“skip-grant-tables”用來跳過密碼驗證的過程,保存文檔並退出 //vim /etc/my.cnf
(2) 重啟mysql // service mysql restart
(3)mysql // 免密登陸
(4)use mysql;
update mysql.user set authentication_string=password('你的新密碼') where user='root'; // 注意password()是個函數,負責加密密碼,不要刪除
flush privileges;
(5)刪除/etc/my.cnf中的skip-grant-tables
(6)重啟mysql服務
