程序员

mysql安装后操作(一)

2019-04-18  本文已影响0人  六月繁花开

https://juejin.im/post/5cad39b3f265da03502b1c0a#heading-5

1. 查看用户:

mysql> use mysql;
mysql> select host,user from mysql.user;

+------------+------+
| host       | user |
+------------+------+
| 127.0.0.1  | root |
| ::1        | root |
| localhost  |      |
| localhost  | root |
| server.gao |      |
| server.gao | root |
+------------+------+

2. 创建用户:

mysql> create user 'usrabc'@'%' identified by 'usrabc';

mysql> select host,user from mysql.user;
+------------+--------+
| host       | user   |
+------------+--------+
| %          | usrabc |
| 127.0.0.1  | root   |
| ::1        | root   |
| localhost  |        |
| localhost  | root   |
| server.gao |        |
| server.gao | root   |
+------------+--------+

3. 查看当前登录用户

mysql> select user();
+----------------+
| user() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)

4. 查看当前数据库

mysql> select database();
+--------------------+
| database() |
+--------------------+
| information_schema |
+--------------------+
1 row in set (0.00 sec)

4. 删除用户

mysql> use mysql;
mysql> DELETE FROM user WHERE HOST='localhost' AND User="test2";
+------------+------+
| host       | user |
+------------+------+
| 127.0.0.1  | root |
| ::1        | root |
| localhost  |      |
+------------+------+
query OK;
上一篇下一篇

猜你喜欢

热点阅读