MySQL用戶管理,經常使用MySQL語句、MySQL數據庫備份恢復

12月6日任務mysql

13.4 mysql用戶管理linux

13.5 經常使用sql語句sql

13.6 mysql數據庫備份恢復數據庫

 

13.4 mysql用戶管理ide

  • 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 user2@192.168.133.1;

 

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

[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)get

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.input

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.it

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.io

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)
 

 

 

13.5 經常使用sql語句

  • select count(*) from mysql.user;       # count(*)表示查找這個表的行數
  •  select * from mysql.db;
  •  select db from mysql.db;
  •  select db,user from mysql.db;
  •  select * from mysql.db where host like '192.168.%';
  •  insert into db1.t1 values (1, 'abc');
  •  update db1.t1 set name='aaa' where id=1;
  •  truncate table db1.t1;
  •  drop table db1.t1;
  •  drop database db1;
相關文章
相關標籤/搜索