现在的位置: 首页 > 综合 > 正文

设置mysql允许远程链接

2013年06月04日 ⁄ 综合 ⁄ 共 447字 ⁄ 字号 评论关闭

第一步,增加新用户

格式: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 "";

第二步,进入/etc/mysql/my.cnf,找到bind-address   = 127.0.0.1,将其注释掉,然后自毁执行/etc/init.d/mysql restart重启.

抱歉!评论已关闭.