mysql用户远程访问设置.md

 

远程访问报错

 

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

 很明显root用户只有在localhost主机下访问mysql服务的权限,那接下来要做的就是赋予能在其他主机上访问该mysql服务的权限即可。

 

 

 

改表法

 

#1. 以root用户登录mysql服务
$ mysql -uroot -p
# 输入mysql root用户密码
#2. 查看当前用户
mysql> select user,host,password from user;
+-----------+---------------+-------------------------------------------+
| user      | host          | password                                  |
+-----------+---------------+-------------------------------------------+
| root      | localhost     | *23AE809DDACAF96AF0FD78ED04A6A265E05AA*** |
| root      | futeng-oracle |                                           |
| root      | 127.0.0.1     |                                           |
|           | localhost     |                                           |
|           | futeng-oracle |                                           |
+-----------+---------------+-------------------------------------------+
#3. 更改root用户可在任意主机访问,注意只要设置 host=% 即可
update mysql.user set host = '%' where user = 'root' and host='localhost';
#4. 刷新权限
flush privileges;

 

 

 

直接赋权限法

#直接赋所以地点均可访问的权限
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
#也可指定该用户只能在某台主机上面有访问该mysql服务的权限
GRANT ALL PRIVILEGES ON *.* TO '用户'@'192.168.1.101' IDENTIFIED BY '密码' WITH GRANT OPTION;

 以上两个种方法看个人口味任选其一即可。


 

 

 

转载请标明作者和 原文链接
ifuteng#gmail.com 2014/9/4

 

猜你喜欢

转载自futeng.iteye.com/blog/2113352