1. 登录系统
~~~
[root@izbp192gcqz9hrnj21lewuz ~]# mysql -uroot -**** -h47.96.121.127 -P 3306
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 5.6.36 Source distribution
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
~~~
2. 查看当前用户
~~~
mysql> select user();
+--------------------+
| user() |
+--------------------+
| root@47.96.121.127 |
+--------------------+
1 row in set (0.00 sec)
~~~
3. 查看当前用户授权
~~~
mysql> show grants for 'root'@'%';
+------------------------------------------------------------------+
| Grants for root@% |
+------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'root'@'%' IDENTIFIED BY PASSWORD <secret> |
| GRANT ALL PRIVILEGES ON `champion`.* TO 'root'@'%' |
+------------------------------------------------------------------+
2 rows in set (0.00 sec)
~~~
4. 远程用户没有创建用户的权限
~~~
mysql> CREATE USER 'log'@'*' IDENTIFIED BY 'log2018';
ERROR 1227 (42000): Access denied; you need (at least one of) the CREATE USER privilege(s) for this operation
~~~
~~~
mysql> select user();
+--------------------+
| user() |
+--------------------+
| root@47.96.121.127 |
+--------------------+
1 row in set (0.00 sec)
~~~
5. 本机用户有创建用户的授权权限
~~~
mysql> show grants for 'root'@'localhost';
+-----------------------------------------------------------------------------------------------------+
| Grants for root@localhost |
+-----------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD <secret> WITH GRANT OPTION |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION |
+-----------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
~~~
6. exit登出系统
~~~
mysql> exit
Bye
~~~
7. 本地用户登陆
~~~
[root@izbp192gcqz9hrnj21lewuz ~]# mysql -uroot -**** -hlocalhost -P 3306
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 5.6.36 Source distribution
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
~~~
~~~
mysql> select user();
+----------------+
| user() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)
~~~
8. 创建新用户
~~~
mysql> CREATE USER 'log'@'*' IDENTIFIED BY 'log2018';
Query OK, 0 rows affected (0.00 sec)
~~~
9. 授权用户
~~~
mysql> GRANT ALL PRIVILEGES ON champion.* TO log@"%" IDENTIFIED BY "log2018";
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
~~~
- 授权管理
- 角色管理
- 设置密码
- 5.6 版本
- 系统用户
- 当前用户
- 目录
- 设计规划
- 数据字典
- 状态监控
- 查看MYSQL表占用空间状态
- show table status
- SHOW 命令
- SHOW TABLE STATUS
- 表格输出
- 调优
- 书籍培训
- 数据库管理员的第一本书(原书第2版)
- 视频
- 收获,不止SQL优化
- 基本概念
- 工具
- phpMyadmin
- 变更管理
- 数据关系与原则
- 数据完整性
- 业务完整性
- 字段更新(1)
- 订单应用(1)
- 订单应用(2)
- 表间数据连接
- 数据管理
- Cheet Sheet
- Database Administrator
- 索引设计
- Mysql 四种常见的索引
- MySQL索引之主键索引
- MySQL索引使用对查询、插入速度的影响
- 查询优化
- 存储优化
- 分割数据表字段
- Procedure_Analyse优化表结构
- 性能优化
- 拆分DELETE/INSERT语句
- MySQL命令
- 表复制
- 如何快速创建相同结构的表
- 主键设计
- 为什么推荐InnoDB引擎使用自增主键?
- INFORMATION_SCHEMA
- _5.6版本
- USER_PRIVILEGES