MySQL远程连接常见问题

注意:云服务器安全组规则允许3306端口访问(防火墙允许3306端口访问)

*Host is not allowed to connect to this MySQL server**

使用root权限登入MySQL,更改"mysql"数据库里的"user"表里的"Host"字段,从"localhost"改为’%’

$ mysql -u root -p
>> use mysql;
>> select * from `user`;
>> update `db` set `Host` = '%' where `db`.`Host` = 'localhost' and `db`.`Db` = 'db-name' and `db`.`User` = 'db-user';
>> update `db` set `Host` = '%' where `db`.`Host` = 'localhost' and `db`.`Db` = 'db-name\\_%' and `db`.`User` = 'db-user';
>> update `user` set `Host` = '%' where `user`.`Host` = 'localhost' and `user`.`User` = 'db-user';
>> flush privileges;
  • db-user: 数据库用户名

Access denied for user ‘db-user’@’%’ to database ‘db-name’

grant all on db-name.* to 'db-user'@'%' identified by 'db-password' with grant option;
  • db-name: 数据库名称
  • db-user: 数据库所属用户
  • db-password: 数据库用户登录密码
上一篇 Laravel报错Unknown column 'updated_at' in 'field list'
下一篇 通过phpMyAdmin设置MySQL允许远程连接
目录
文章列表
1 Nodejs crypto密码模块
Nodejs crypto密码模块
2
Redis HyperLogLog
Redis HyperLogLog
3
logstash.outputs.elasticsearch retrying failed action with response code 403
logstash.outputs.elasticsearch retrying failed action with response code 403
4
CentOS 7 下搭建NFS服务
CentOS 7 下搭建NFS服务
5
利用XStream在Java对象和XML之间相互转换
利用XStream在Java对象和XML之间相互转换
最新评论
一位WordPress评论者
一位WordPress评论者
2月12日
您好,这是一条评论。若需要审核、编辑或删除评论,请访问仪表盘的评论界面。评论者头像来自 Gravatar。