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