mysql> show databases; ##查看数据库;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
mysql> drop database test; ##删除test库;
Query OK, 0 rows affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
mysql> select user,host from mysql.user; ##查看用户列表;
+------+---------------+
| user | host |
+------+---------------+
| root | 127.0.0.1 |
| root | ::1 |
| | Mysql\_server |
| root | Mysql\_server |
| | localhost |
| root | localhost |
+------+---------------+
6 rows in set (0.00 sec)
mysql> drop user root@'::1'; ##删除无用用户
Query OK, 0 rows affected (0.00 sec)
mysql> drop user ''@'Mysql\_server'; ##对于大写、特殊字符删除不了,下面有介绍
Query OK, 0 rows affected (0.00 sec)
mysql> drop user ''@'localhost';
Query OK, 0 rows affected (0.01 sec)
mysql> drop user 'root'@'Mysql\_server'; 对于大写、特殊字符删除不了,下面有介绍
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host from mysql.user;
+------+---------------+
| user | host |
+------+---------------+
| root | 127.0.0.1 |
| | Mysql\_server |
| root | Mysql\_server |
| root | localhost |
+------+---------------+
4 rows in set (0.00 sec)
对于大写、特殊字符删除不了解决办法:
mysql> delete from mysql.user where user="" and host="Mysql\_server";
Query OK, 1 row affected (0.02 sec)
mysql> delete from mysql.user where user="root" and host="Mysql\_server";
Query OK, 1 row affected (0.00 sec)
mysql> select user,host from mysql.user; ##将无用用户删除以后,查看用户列表
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| root | localhost |
+------+-----------+
2 rows in set (0.00 sec)
mysql> flush privileges; ##最后使得权限生效
Query OK, 0 rows affected (0.00 sec)
创建用户sql语句:
mysql> grant all on *.* to 'root'@'localhost' identified by '123456' with grant option;flush privileges;
CentOS7编译安装MySQL 5.6.28和编译参数
Ubuntu 14.04下安装MySQL