flush privileges;mysql
1.修改ROOT密碼:sql
alter user 'root'@'localhost' identified by '123';數據庫
2.取消密碼複雜要求:ide
set global validate_password_policy=0;spa
3.查看密碼長度:索引
select @@validate_password_length;ci
4.查看mysql當前有哪些用戶:it
SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;table
4.1查看用戶權限.ast
show grants from user;
5.鎖表:
flush tables with read lock;
6.解表:
unlock tables;
7.查看鎖表時間
show variables like '%timeout%';
8.建立用戶方式:
grant all privileges on 庫名.* to admin@'%' identified by '123456'; (受權庫)
CREATE USER 'username'@'host' IDENTIFIED BY 'password'; (單建立用戶)
9.建立主從帳號(在主數據庫建立)
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%' IDENTIFIED BY 'password';
9.1.主庫查詢當前master的bin-log
show matser status;
10.從庫鏈接主庫方式:
CHANGE MASTER TO
MASTER_HOST='主庫IP',
MASTER_PORT=3306,
MASTER_USER='repl',
MASTER_PASSWORD='主庫建立的密碼',
MASTER_LOG_FILE='mysql-bin.000002',
MASTER_LOG_POS=154;
11.啓用mysql帳號遠程鏈接
GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "youpassword" WITH GRANT OPTION;
12.收回帳號權限
revoke select on dbname.* from username;
revoke all privileges on dbname[.tbname] from username;
privileges包括:
alter:修改數據庫的表
create:建立新的數據庫或表
delete:刪除表數據
drop:刪除數據庫/表
index:建立/刪除索引
insert:添加表數據
select:查詢表數據
update:更新表數據
all:容許任何操做
usage:只容許登陸
13. 建立mysql庫
create database mobile DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
14.刪除用戶
DROP USER 'username'@'host';
15.刪除庫:
drop database dbname;