[數據庫]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';