mysql常用命令

來源:互聯網
上載者:User

標籤:

1、在linux上安裝mysql用戶端,然後通過以下命令進入mysql控制台,然後就可以執行各種sql語句了:

mysql -h10.2.120.1 -utest -p123456
use db1

其中,10.2.120.1是mysql的ip地址,預設連接埠號碼3306,test是使用者名稱,123456是密碼,db1是資料庫執行個體的名稱。

 

2、執行以下命令,匯出整個資料庫的SQL指令碼(表結構+資料):

mysqldump -h10.2.120.1 -utest -p123456 db1 > ./db1.sql

其中,db1是資料庫執行個體的名稱。

 

3、匯出指定資料庫中指定表的結構和資料:

mysqldump -h10.2.120.1 -utest -p123456 db1 table1 > ./table1.sql

其中,db1是資料庫執行個體的名稱,table1是要匯出的表的名稱。

 

4、匯出指定資料庫中指定表的結構和資料,使用指定where條件進篩選:

mysqldump -h10.2.120.1 -utest -p123456 db1 table1 --where="xxx" > ./table1.sql

其中,db1是資料庫執行個體的名稱,table1是要匯出的表的名稱,xxx是where條件。

 

5、查看mysql資料庫狀態:

mysql> status;

 

6、查看指定變數的值:

mysql> show variables like ‘%max_connections%‘;

7、查看當前執行的命令列表:

mysql> show processlist;

 

8、終止指定的命令:

mysql> kill process_id

可以通過show processlist命令擷取具體的process_id。

 

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.