ubuntu mysql服务器开启远程访问
1. ubuntu 安装mysql
$ sudo apt-get install mysql-server mysql-client
2. 给root用户一个远程访问的权限
$ mysql -uroot -p
输入密码后
mysql> GRANT ALL PRIVILEGES ON *.* TO root@'%' Identified by "fztree";
说明
增加新用户 格式:grant 权限 on 数据库.* to 用户名@登录主机 identified by "密码" 如,增加一个用户user1密码为password1,让其可以在本机上登录, 并对所有数据库有查询、插入、修改、删除的权限。 首先用以root用户连入mysql,然后键入以下命令: grant select,insert,update,delete on *.* to user1@localhost Identified by "password1"; 如果希望该用户能够在任何机器上登陆mysql,则将localhost改为"%"。 如果你不想user1有密码,可以再打一个命令将密码去掉。 grant select,insert,update,delete on mydb.* to user1@localhost identified by ""; 如果你一开始就不打算设置密码 grant select,insert,update,delete on *.* to user1@localhost; 参考 http://www.cnblogs.com/good_hans/archive/2010/03/29/1700046.html
3.修改配置文件,解绑127.0.0.1
$ sudo vi /etc/mysql/my.cnf
找到 bind-address = 127.0.0.1
扫描二维码关注公众号,回复:
591513 查看本文章
改为 bind-address = 0.0.0.0
4.重启mysql服务器
$ sudo ufw allow mysql $ sudo service mysql restart