显示所有用户,mysql的基本操作

来源:互联网 发布:js代码解压缩 编辑:程序博客网 时间:2024/05/30 04:29
可以实现显示数据库中所有用户。
select user from mysql.user;
select user,host,password from mysql.user;
 
给表创建用户,授权:

The create user command:

<!---->mysql> CREATE USER yy IDENTIFIED BY '123';

yy表示你要建立的用户名,后面的123表示密码

上面建立的用户可以在任何地方登陆。

如果要限制在固定地址登陆,比如localhost 登陆:

<!---->mysql> CREATE USER yy@localhost IDENTIFIED BY '123';

grant:

<!---->mysql> GRANT ALL PRIVILEGES ON *.TO user;@localhost

 

<!---->grant select,insert,update,delete on *.* to test1@"%" Identified by "abc";

grant select,insert,update,delete on *.* to test1@"%" Identified by "abc";

格式:grant select on 数据库.* to 用户名@登录主机 identified by "密码"

 

 

修改密码:

 

<!---->mysql> grant   all   privileges   on   pureftpd.*   to   koko@localhost   identified   by   'mimi'; 

flush:

<!---->mysql> flush privileges;

 

 

查看用户信息:

<!---->mysql> select host,user from mysql.user;


0 0
原创粉丝点击