在远程主机上开启了mysql 服务,用Navicat for MySQL客户端打开,比如说用户名为 root,密码为 123456。不过用 Mysql 客户端远程连接时报错误,错误代码如下:Access denied for user ‘root'@'121.42.8.33′(using password:YES)
新建用户,然后授予所有 IP 可以访问的权限,具体解决方法如下:CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' WITH GRANT OPTION;
CREATE USER 'username'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' WITH GRANT OPTION;
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' WITH GRANT OPTION;
CREATE USER 'username'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' WITH GRANT OPTION;
通过执行以上语句,便创建了一个用户名为 username,密码为 password 的新账户,再用新账号登录,即可连接成功。