Developer Linux > MySQL config

From Geneabase
Jump to: navigation, search

Make sure mysql is installed:

 yum install mysql-server

Mysql database files are placed in /var/data/mysql:

 mkdir -p /var/data/mysql
 chown mysql:mysql /var/data/mysql

Since we have SELinux enabled, we need to add a rule to allow mysql access to this directory:

 semanage fcontext -a -t  mysqld_db_t "/var/data/mysql(/.*)?"

You can verify that this rule has been applied with the following command:

 grep mysql /etc/selinux/targeted/contexts/files/file_contexts.local

Since semanage does not relabel files, relabel the directory with this command:

 restorecon -v -R /var/data/mysql

Make sure you've also executed

restorecon -v /var/data

if you have just created that directory (otherwise, mysql can't read that directory since it is not labeled var_t).

Create the file /etc/my.conf so it contains the following:

 
[mysqld]
socket=/var/lib/mysql/mysql.sock
datadir=/var/data/mysql
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
innodb_log_file_size=1Gb
innodb_buffer_pool_size=2Gb
log=/var/log/mysqld.log

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

set the security context:

 restorecon -v /etc/my.cnf

you should now be able to start mysql:

 service mysqld start

make sure mysql is booted at system startup:

 chkconfig mysqld --level 345 on

configure a password for root, remove anonymous users, disallow remote root access, remove test database, reload privilege tables:

/usr/bin/mysql_secure_installation
Personal tools
Namespaces
Variants
Actions
Geneabase newsletter
* indicates required
Architecture
Webservices
Datamodel
Import / Export
Participation
Developer Linux
Developer Microsoft
Print/export
Toolbox