设置mysql远程链接

来源:互联网 发布:淘宝达人账号如何注销 编辑:程序博客网 时间:2024/05/19 20:41

一、      进入mysql数据库

mysql  -uroot –p密码

 

二、      创建用户进行远程链接

Mysql>grant all privileges on *.* to 'duan'@'%'identified by '111111' with grant option;

*.* : 表示给该用户指定所有的数据库,如果换成grant all privileges on test.* to duan:@'%' identified by '123654',则表示给该用户仅指定test数据库。

‘duan’ : 用户名

  ‘%’ :表示所有主机都可以登录,如果‘ip’表示该主机可以的登录

‘111111’:密码

三、      执行flush privileges,是命令立即生效

mysql>flush privileges

 

四、      重启

Exit退出mysql数据库执行

Service mysql stop

Service mysql start

 

五、      查看端口号

lsof  –i:3306

出现以下信息,表示端口已经打开:

COMMAND PID  USER   FD  TYPE DEVICE SIZE/OFF NODE NAME

mysqld 4421 mysql   10u  IPv6 56073      0t0  TCP *:mysql (LISTEN)

 

六、      使用SQLyog测试远程登录

远程链接成功!!!!

附写:

删除用户delete from user where user='duan' and host='ip';flush privileges;删除用户数据库drop database test;修改指定用户密码update user set password=password('new_password') where user='duan' and host='ip';flush privileges;

0 0
原创粉丝点击