Apparently the best place to add configuration settings to the MySQL server is the [mysqld] stanza of /etc/my.cnf (see the query log example below). The default Red Hat install does very little logging.
To see what settings a running mysqld is using, connect and run SHOW VARIABLES; and for a short explanation use /usr/libexec/mysqld --verbose --help or the MySQL.com documentation.
Adding a query log
Add this to /etc/my.cnf:
[mysqld] log-long-format log=/var/log/mysql/query.log
Create a place for the query log:
touch /var/log/mysql/query.log chmod 600 /var/log/mysql/query.log chown mysql.mysql /var/log/mysql/query.log /etc/init.d/mysql restart
To rotate the logs, create this /etc/logrotate.d/mysql-query file: You need a /root/.my.cnf configuration file with a [mysqladmin] entry for the logrotate to work
/var/log/mysql/query.log {
create 600 mysql mysql
weekly
rotate 40
missingok
compress
postrotate
# just if mysqld is really running
if test -n "`ps acx|grep mysqld`"; then
/usr/bin/mysqladmin --defaults-extra-file=/root/.my.cnf flush-logs
fi
endscript
}
Adding a user
Log in as the root user with mysql mysql:
GRANT ALL PRIVILEGES ON main_db.* to foo@'localhost' identified by 'bar'; GRANT ALL PRIVILEGES ON main_db.* to foo@'%' identified by 'bar';
