Skip to content

Instantly share code, notes, and snippets.

@kymtwyf
Last active October 15, 2015 02:30
Show Gist options
  • Save kymtwyf/0d62d3bcd94c2c2c94aa to your computer and use it in GitHub Desktop.
Save kymtwyf/0d62d3bcd94c2c2c94aa to your computer and use it in GitHub Desktop.
Mysql允许远程访问

先修改/etc/init.d/my.cnf 下

bind-ipaddress = 0.0.0.0(原来是127.0.0.1)

Reference for all ips use below以下命令允许所有IP访问

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' WITH GRANT OPTION;

for particular ip use below以下命令只允许myuser用户通过youripaddres这个IP访问

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'youripaddres' WITH GRANT OPTION;

最后需要做一个FLUSH操作

FLUSH PRIVILEGE

还有一个关于mysql user的说明 Mysql 将user存储在mysql数据库的user表中,可能如: 图片 同在一个user对于不同host可以有不同的密码,比如上图中root对于%的密码是没有的,为空。但对于localhost等的密码却存在值(% wildcard host,和localhost不一样) 这个时候如果需要设置成一样的话就:

  update user set password=PASSWORD("newpassword") where User='root';

更新完毕用户名的密码后重新启动一下mysql就好了~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment