当前位置 博文首页 > tongtongsong的博客:ERROR 1044 (42000): Access denied for us
?使用MySql(非root用户)时 操作数据库报错(权限问题);
错误翻译:
错误1044(42000):拒绝用户“test”@“localhost”访问数据库“testDB’? ?(testDB是测试数据库名)
?
解决这类问题(就是给用户授权)
用户授权
授权格式:grant?权限 on?数据库.* to?用户名@登录主机 identified by "密码";
1、登录MYSQL(有ROOT权限),这里以ROOT身份登录:
@>mysql -u root -p
@>密码
2、 首先为用户创建一个数据库(testDB):
mysql>create database testDB;
3、 授权test用户拥有testDB数据库的所有权限(某个数据库的所有权限):
?mysql>grant all privileges on testDB.* to test@localhost identified by '1234';
? mysql>flush privileges;//刷新系统权限表
格式:grant?权限 on?数据库.* to?用户名@登录主机 identified by "密码";
4、 如果想指定部分权限给一用户,可以这样来写:
mysql>grant select,update on testDB.* to test@localhost identified by '1234';
mysql>flush privileges; //刷新系统权限表
5、 授权test用户拥有所有数据库的某些权限:? ?
mysql>grant select,delete,update,create,drop on *.* to test@"%" identified by "1234";
?????//test用户对所有数据库都有select,delete,update,create,drop?权限。
?
亲自使用过没问题!
最后推荐像我一样操作mysql数据库命令不太熟悉的人? 可以看下这篇文章 :https://www.cnblogs.com/pengyunjing/p/6181684.html? ;??
(总结的还是比较全面的!!!)
cs