Ubuntu18.04 修改Mysql5.7默認root密碼


步驟

  • 設置mysql免密碼登陸
    編輯/etc/mysql/my.cnf文件,在最后加入以下設置
[mysqld]
skip-grant-tables=1
  • 重啟mysql
$ sudo service mysql stop
$ sudo service mysql strat
  • 進入mysql,先修改驗證方式,再改密碼
$ mysql
//修改驗證方式
mysql> USE mysql;
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
//修改密碼
mysql> update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';
//刷新權限
mysql> flush privileges;
//推出
musql> exit;
  • 重啟mysql服務 登陸mysql
$ mysql -uroot -p

參考

https://stackoverflow.com/questions/39281594/error-1698-28000-access-denied-for-user-rootlocalhost#


免責聲明!

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



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