標籤:-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常用命令