MySQL常用命令

來源:互聯網
上載者:User

標籤:-name   bsp   取資料   substring   亂碼   host   info   tab   thread   

 1、查看mysql鎖表進程。

1 查看鎖表進程。2 SELECT * FROM information_schema.INNODB_TRX\G3 trx_mysql_thread_id:111114 5 殺死結表進程。6 kill 11111

2、全域唯讀

1 #設定全域唯讀2 set global read_only=1;3 4 #取消全域唯讀5 set global read_only=0;

3、擷取資料庫每個ip的串連數

1 #擷取資料庫每個ip的串連數2 # /usr/local/mysql/bin/mysql -u root -h127.0.0.1 -e"show processlist\G;"| egrep "Host\:" | awk -F: ‘{ print $2 }‘| sort | uniq -c 3 4 # /usr/local/mysql/bin/mysql -u root -h127.0.0.1 --skip-column-names -e"show processlist;"|awk ‘{print $3}‘|awk -F":" ‘{print $1}‘|sort|uniq -c5 6 mysql> select SUBSTRING_INDEX(host,‘:‘,1) as ip , count(*) from information_schema.processlist group by ip;

4、手動刪除二進位日誌

1 #手動刪除binlog2 mysql> purge master logs to ‘master-bin.000480‘;    #刪除master-bin.000480之前的二進位日誌

5、全域讀鎖

1 #增加讀鎖2 mysql> flush tables with read lock;3 mysql> unlock tables; #釋放讀鎖

6、建立資料庫已utf8編碼格式及匯入sql檔案亂碼

1 #建立資料庫以utf8格式2 CREATE DATABASE oma DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;3 4 #mysql source命令亂碼

 

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.