关于数据库授权的问题,mysql

来源:互联网 发布:java大数据处理技术 编辑:程序博客网 时间:2024/06/07 08:32

项目中别人的电脑连接我的本地,运行报错:null, message from server: "Host 'PC-20151208BFAQ' is not allowed to connect


才想到还没有给人家赋权限,没有权利访问我的mysql.

百度了下发现很多解答0.0.发现自己挺2的。

1.首先:

cmd 进入 

输入密码=/= 基本都会忘记0.0 1234 啥的。

show datebases;

use mysql;


select *from user;

看看几个用户

然后 grant all privileges on *.* to 'root'@'%' iddentified by 'root' with grant option;


flush privileges;

再看看改过来没

select *from  user;


_________________&&&&&&&&&&&&&&&&&&&&&&& 好了-。-尴尬下面是百度答案,自己笨,我就又重复了变。


解决方法:
1. 改表法


可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"
mysql -u root -pvmware


mysql>use mysql;


mysql>update user set host = '%' where user = 'root';


mysql>select host, user from user;


2. 授权法


例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
如果你想允许用户myuser从ip为220.181.149.27的主机连接到mysql服务器,并使用mypassword作为密码
GRANT ALL PRIVILEGES ON *.* TO 'root'@'220.181.149.27' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;


GRANT ALL PRIVILEGES ON *.* TO 'root'@'220.181.149.27' IDENTIFIED BY '123456' WITH GRANT OPTION;


百度资料查看:http://blog.csdn.net/jinhill/article/details/7585233   大神的

0 0
原创粉丝点击