MySQL用户操作勒

账户的创建大概分为:

 

 

 在MySQL上创建用户:

MariaDB [(none)]> create user first@"localhost" identified by "123456";
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.000 sec)

 

  在MySQL上删除用户:

MariaDB [(none)]> Delete FROM mysql.user Where User='first' and Host='localhost';
Query OK, 1 row affected (0.000 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.000 sec)

 

查看所有用户和对应的信息

MariaDB [(none)]> select user,host,password from mysql.user;
+----------+-----------+-------------------------------------------+
| user     | host      | password                                  |
+----------+-----------+-------------------------------------------+
| root     | localhost | *E6CC90B878B948C35E92B003C792C46C58C4AF40 |
| root     | 127.0.0.1 | *E6CC90B878B948C35E92B003C792C46C58C4AF40 |
| root     | ::1       | *E6CC90B878B948C35E92B003C792C46C58C4AF40 |
| marshall | %         | *E6CC90B878B948C35E92B003C792C46C58C4AF40 |
+----------+-----------+-------------------------------------------+
4 rows in set (0.000 sec)

 默认添加的用户是没有权限的,给用户添加权限:

 

权限:

all privileges:所有权限。

select:  读取权限。

delete:  删除权限。

update: 更新权限。

create:  创建权限。

drop:     删除数据库、数据表权限。

 

给用户修改密码

如果是root类型用户修改其他用户:

MariaDB [(none)]> ~~~
MariaDB [(none)]> update mysql.user set password=("123456") where user="marshall" and host="%";
Query OK, 0 rows affected (0.000 sec)
Rows matched: 1  Changed: 0  Warnings: 0

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.000 sec)

 

 

当前用户修改密码

MariaDB [(none)]> set password = password("1");
Query OK, 0 rows affected (0.000 sec)

 

posted @ 2020-03-17 10:45  5444de  阅读(120)  评论(0编辑  收藏  举报