阿里雲安裝mysql,初始化密碼修改


阿里雲服務器,centos7,

 

rpm包安裝MySQL,初始化了個奇葩密碼

登陸不上,

  1. 修改配置文件/etc/my.cnf,在【mysqld】下面添加一行代碼:skip-grant-tables
  2. service mysqld restart
  3. mysql -uroot -p  //此時直接回車,既可以進入數據庫。
  4. 進數據庫后,use mysql   //選擇mysql這個庫,因為mysql的root密碼存放在這個數據庫里。
  5. show tables  //查看下mysql庫里有哪些表,我們需要操作的用戶名密碼都在user表里。
  6. desc user  //查看下user表有哪些字段。
  7. update user set password=password('123456') where user="root";  //用戶選root,可以隨便更改成任意密碼,我這里設置的123456,password()是mysql密碼加密的一個函數。有些數據要執行update user set authentication_string=password('coship') where user="root";才行
  8. 發現行不通,
  9. 改用ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
  10. 報錯:The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
  11. flush privileges;
  12. 再次:ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
  13. ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
  14. 執行:SHOW VARIABLES LIKE 'validate_password%';
  15. set global validate_password.policy=0;set global validate_password.length=6;
  16. 然后再次執行:ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
  17. Query OK, 0 rows affected (0.03 sec)
  18. over


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM