[數據庫]mysql MySQL報錯-Access denied for user 'root'@'localhost' (using password: NO)


[數據庫]mysql配置連接拒絕無權限解決方法

https://www.cnblogs.com/bjlhx/p/11395992.html

1、新安裝的mysql報錯

MySQL報錯-Access denied for user 'root'@'localhost' (using password: NO)

解決方案

1、先停掉原來的服務

/etc/init.d/mysqld stop

2、使用安全模式登陸,跳過密碼驗證

mysqld_safe --user=mysql --skip-grant-tables --skip-networking&

或者上述兩步可以使用如下操作

  在mysql的配置文件內加入:

  vim  /etc/my.cnf

  skip-grant-tables

  保存並重啟mysql服務

3、進入mysql,修改密碼:

mysql> use mysql;

mysql> update user set password=password("你的新密碼") where user="root";

mysql> flush privileges;

mysql> quit

到此root賬戶就重置了密碼,

  注意:如果使用配置文件了,需要刪除etc/my.cnf中,剛添加的那行內容,重啟mysql就好了

更新密碼出錯

  mysql> update user set password=password("你的新密碼") where user="root";

  報錯:ERROR 1054 (42S22): Unknown column 'password' in 'field list'

  解決措施如下:

  mysql>desc user;

  發現在Field列中沒有password,此時我們需要這樣重置密碼:

  mysql>update user set authentication_string=password('123456') where user='root';

 


免責聲明!

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



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