Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Linux Ask!

Jan 122010
 

Enable slow query log in MySQL

Answer:

Turn on the Slow Query log in MySQL allow you to debug the sources of slow and problematic SQL.

To activate it, edit the MySQL configurations, e.g. /etc/my.cnf

[mysqld]
...
...
log-slow-queries        = /var/log/mysqld-slow.log                                                                                
long_query_time         = 5     

Restart MySQL and you will notice the file mysqld-slow.log will be created.

Any queries take more than 5 seconds to execute will be logged in this file.

Jan 112010
 

Display current login user information

Answer:

To check your Linux username, use whoami

$ whoami

john

To see your User ID (UID), Group ID (GID) and who groups you belong to, use the command id

$ id

uid=1000(john) gid=100(users) groups=33(www-data),100(users)