mysql常用命令

mysql> show variables like '%bind_address%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| bind_address  | *     |
+---------------+-------+
mysql> show grants for root@localhost;
+---------------------------------------------------------------------+
| Grants for root@localhost                                           |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION        |
+---------------------------------------------------------------------+
mysql> select user,host from mysql.user;
+---------------+-----------+
| user          | host      |
+---------------+-----------+
| mysql.session | localhost |
| mysql.sys     | localhost |
| root          | localhost |
+---------------+-----------+
# 创建用户 并刷新权限
mysql> create user adq@localhost identified by "cdq";
Query OK, 0 rows affected (0.00 sec)
# 所有权限
mysql> grant all privileges on *.* to adq@localhost;
Query OK, 0 rows affected (0.00 sec)
# order库下所有表的select权限
mysql> grant select on order.* to adq@localhost;
Query OK, 0 rows affected (0.00 sec)
# order库下所有表的select权限 并且只能查询id列
mysql> grant select(id) on order.* to adq@localhost;
Query OK, 0 rows affected (0.00 sec)

# order库下所有表的select,insert,update,delete权限
mysql> grant select,insert,update,delete on order.* to adq@localhost;
Query OK, 0 rows affected (0.00 sec)
原文地址:https://www.cnblogs.com/huameixiao/p/14701480.html