如何实现远程访问mysql数据库
打开mysql配置文件vi /etc/mysql/my.cnf
将bind-address = 127.0.0.1注销
查看端口是否打开 netstat -an|grep 3306
1.新建一个mysql账户,用于远程登录
mysql> insert into mysql.user(Host,User,Password) values("localhost","hackywit",password("123456"));
localhost为本地登录,远程除本地用户用%表示。
2.给新用户访问权限,否则连mysql的shell都进不去
mysql> grant all privileges on *.* to hackywit@localhost identified by '123456';
mysql> flush privileges;//刷新系统权限表,不刷新是不行的
mysql> select host,user from mysql.user;//查看是否权限修改成功
授权格式:grant 权限 on 数据库.表 to 用户名@登录主机 identified by "密码";
权限可以是select,update等具体的数据库操作。
3.删除权限
mysql> drop user hackywit@localhost;
4.修改用户密码
mysql> update mysql.user set password=password("hackywit") where User="hackywit" and Host="localhost";
5.删除mysql用户
mysql> use mysql
mysql> delete from user where User='polaris' and Host='localhost';
mysql> flush privileges;
[mysql远程连接参考][1]
[1]:http://jingyan.baidu.com/article/046a7b3ed85f3ef9c27fa9dc.html