問題描述:
1045-Access denied for user 'root'@'localhost'(using password: YES)
方法:
操作系統爲CentOS系列
注意:一定要重啓mysql服務或者重啓服務器
1、針對一對一用戶
# mysql -uroot -p
MySQL [(none)]> grant all privileges on db_name.* to db_user@’%’ identified by ‘db_pass’; #授權語句,特別注意有分號
MySQL [(none)]> flush privileges;
MySQL [(none)]> exit; #退出數據庫控制檯,特別注意有分號
重啓MYSQL:service mysqld restart
2、針對總帳號root 即一個帳號管理所有數據庫
grant all privileges on * to root@’%’ identified by ‘dsfdfggdg41;
引用:https://oneinstack.com/docs/lnmpstack-image-guide/
如何配置MySQL遠程連接 >> 3. 數據庫授權