Mysql命令匯總

來源:互聯網
上載者:User

標籤:mysql

             flush privileges;

1.修改ROOT密碼:

alter user ‘root‘@‘localhost‘ identified by ‘123‘;


2.取消密碼複雜要求:

set global validate_password_policy=0;


3.查看密碼長度:

select @@validate_password_length;


4.查看mysql當前有哪些使用者:

 SELECT DISTINCT CONCAT(‘User: ‘‘‘,user,‘‘‘@‘‘‘,host,‘‘‘;‘) AS query FROM mysql.user;


4.1查看使用者權限.

show grants from user;


5.鎖表:

flush tables with read lock;


6.解表:

unlock tables;


7.查看鎖表時間

show variables like ‘%timeout%‘;


8.建立使用者方式:

grant all privileges on 庫名.* to [email protected]‘%‘ 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 [email protected]"%" IDENTIFIED BY "youpassword" WITH GRANTOPTION; 

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.刪除使用者

DELETE FROM user WHERE User="username" and Host="localhost";


15.刪除庫:

drop database dbname;

本文出自 “一招拜師” 部落格,請務必保留此出處http://sadoc.blog.51cto.com/12189157/1965227

Mysql命令匯總

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.