HostOnNet Blog

MySQL Configuration

Here are some of the configurations for MySQL, some of these are already set on your server. When you edit MySQL configuration file (/etc/my.cnf or /etc/mysql/my.cnf), you need to restart MySQL as it is only read when you start MySQL.

Log File

In /etc/my.cnf, under section [mysqld] add

log_error = /var/log/mysql/error.log

You need to create the folder

mkdir /var/log/mysql
chown -R mysql:mysql /var/log/mysql

If you are using MariaDB, it already do this. MySQL on CentOS store logs in /var/lib/mysql/HOSTNAME.err file.

Network settings

You can add


in /etc/my.cnf, under [mysqld] section to disable networking. You will need to connect with socket. By default when you use “localhost” in PHP script to connect, you are using socket.

It is better keep networking enabled, but set MySQL to listen to local IP only ( by adding

bind-address =



Posted in MySQL