linux mysql增加用户,删除用户,以及用户权限

一些基本的命令:

登录:

mysql -u username -p

显示所有的数据库:

show databases;

使用某一个数据库:

use databasename;

显示一个数据库的所有表:

show tables;

退出:

quit;

删除数据库和数据表mysql>drop database 数据库名;mysql>drop table 数据表名;

用户相关:

查看所有的用户:

SELECT DISTINCT CONCAT(‘User: ”’,user,”’@”’,host,”’;’) AS query FROM mysql.user;

新建用户:

insert into mysql.user(Host,User,Password) values("localhost","test",password("1234"));

最后三个参数,,分别是登录ip,用户名,密码

为用户授权:

格式:

grant 权限 on 数据库.* to 用户名@登录主机 identified by "密码";

示例:

grant all privileges on testDB.* to test@localhost identified by ‘1234’;

然后需要执行刷新权限的命令:

flush privileges;

为用户授予部分权限:

grant select,update on testDB.* to test@localhost identified by ‘1234’;

授予一个用户所有数据库的某些权限:

grant select,delete,update,create,drop on *.* to test@"%" identified by "1234";

删除用户:

Delete FROM user Where User=’test’ and Host=’localhost’;

然后刷新权限;

删除账户及权限:>drop user 用户名@’%’;        >drop user 用户名@ localhost;

修改指定用户密码使用root登录:mysql -u root -p执行命令:update mysql.user set password=password(‘新密码’) where User="test" and Host="localhost";刷新权限:flush privileges;

版权声明:本文为博主原创文章,未经博主允许不得转载。

接受失败,是我们不常听到或看到的一个命题,我们大都接受的是正面的教育,

linux mysql增加用户,删除用户,以及用户权限

相关文章:

你感兴趣的文章:

标签云: