Pages

Wednesday, 11 June 2014

Mysql admin

Running mysql commands stored in a file without headers (Batch mode):

mysql --skip-column-names -h10.10.1.50 -u<username> -p < batch_file.txt

Execute mysql in one line,
mysql -u<user> -p -e "show processlist"

"show proceslist" shows you which threads are running. This statement is very useful if you get the too many connections error message and want to find out what is going on.

mysql> show FULL processlist; 
+-------+----------+---------------------+--------+---------+------+-------+-----------------------+
| Id    | User     | Host                | db     | Command | Time | State | Info                  |
+-------+----------+---------------------+--------+---------+------+-------+-----------------------+
| 20484 | User1 | localhost           | NULL   | Sleep   | 1381 |       | NULL                  |
| 20485 | User1 | 172.16.95.15:49580 | portal | Sleep   | 3056 |       | NULL                  |


mysql> show FULL processlist\G
*************************** 1. row ***************************
     Id: 20484
   User: user1
   Host: localhost
     db: NULL
Command: Sleep
   Time: 1414
  State:
   Info: NULL
*************************** 2. row ***************************
     Id: 20485
   User: user1
   Host: 172.16.95.15:49580
     db: portal
Command: Sleep
   Time: 3089
  State:
   Info: NULL

No comments:

Post a Comment