如何实现远程访问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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容