ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 的 问题

=============================================================
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
=============================================================
针对的服务器: AWS EC2
STEP 1: 设置EC2 的安全组

EC2默认防火墙是阻断所有流量,因此在EC2的Scurity Groups中除了其他必要的规则之外,还要添加一条入口流量规则:TCP的3306端口的任意源IP的连接都允许


STEP 2: 修改 MySQL的配置文件

vim /etc/mysql/mysql.conf.d/mysqld.cnf

添加一行 skip-grant-tables,跳过密码校验

user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
skip-grant-tables

ESC + :wq 保存并退出
重启mysql,再无密码登陆

sudo service mysql restart
mysql

STEP 3: MySql默认只允许从本机访问,远程访问要在Terminal中执行:

use mysql
update user set Host='%' where User='root'

REFERENCE:

https://blog.csdn.net/qq_37604508/article/details/78844288

https://blog.csdn.net/timberwolf_2012/article/details/47350215

你可能感兴趣的:(ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 的 问题)