1. 程式人生 > >MySQL使用者管理,常用MySQL語句、MySQL資料庫備份恢復

MySQL使用者管理,常用MySQL語句、MySQL資料庫備份恢復

12月6日任務

13.4 mysql使用者管理

13.5 常用sql語句

13.6 mysql資料庫備份恢復

 

13.4 mysql使用者管理

  • grant all on *.* to 'user1' identified by 'passwd';
  •  grant SELECT,UPDATE,INSERT on db1.* to 'user2'@'192.168.133.1' identified by 'passwd';
  •  grant all on db1.* to 'user3'@'%' identified by 'passwd';
  •  show grants;
  •  show grants for [email protected];

 

#操作過程。
mysql> grant all on *.* to 'user1'@'127.0.0.1' identified by '123456';
Query OK, 0 rows affected (0.01 sec)

[root@zgxlinux-01 ~]# mysql -uuser1 -p123456
Warning: Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'user1'@'localhost' (using password: YES)
[root@zgxlinux-01 ~]# mysql -uuser1 -p123456 -h127.0.0.1
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 5
Server version: 5.6.39 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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> show grants for user1@'127.0.0.1';                #檢視指定使用者的授權
+-----------------------------------------------------------------------------------------------------------------------+
| Grants for user1@127.0.0.1                                                                                            |
+-----------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'user1'@'127.0.0.1' IDENTIFIED BY PASSWORD '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9' |
+-----------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)