Install and Configure MySQL Database Server on RHEL

How do I install the MySQL database server under Redhat Enterprise Linux 4 / 5 / 6?
                                           

MySQL



You can install mysql using any one of the following medium.

a) Install MySQL package using RHN or CentOS repo.
b) Install MySQL rpms from CD/DVD media.

Red Hat Enterprise Linux install Mysql database server

Type the following command to install mysql server using the RHN or CentOS repo:

Redhat Enterprise Linux – RHEL 5 / 6 MySQL installation

Type the following command as root user:
# yum install mysql-server mysql

Redhat Enterprise Linux – RHEL 4/3 MySQL installation

Type the following command as root user:
# up2date mysql-server mysql

Start MySQL Service

To start the mysql server type the following command:
# chkconfig mysqld on
# /etc/init.d/mysqld start

Setup the mysql root password

Type the following command to setup a password for root user:
# mysqladmin -u root password NEWPASSWORD

Test the mysql connectivity

Type the following command to connect to MySQL server:
$ mysql -u root -p

Configure the mysql server

Edit /etc/my.cnf, enter (please note that following are sample values, you need to adjust them as per your requirements):
# vi /etc/my.cnf
You can configure mysql query cache as follows (add in [mysqld] section) to speed up mysql:
 
query_cache_type = 1
query_cache_limit = 1M
query_cache_size = 32M
 
You can setup MyISAM buffer size and recover options:
 
# For MyISAM #
key_buffer_size = 24M
myisam_recover = FORCE,BACKUP
 
Log slow queries for troubleshooting as follows:
 
# LOGGING #
log_queries_not_using_indexes = 1
slow_query_log = 1
slow_query_log_file = /var/lib/mysql/mysqld-slow-query.log
 
Set caches and other limits as follows:
 
tmp_table_size = 32M
max_heap_table_size = 32M
max_connections = 500
thread_cache_size = 50
open_files_limit = 65535
table_definition_cache = 4096
table_open_cache = 512
 
Save and close the file. You can reload or restart the changes as follows:
# /sbin/service mysqld restart
OR
# /sbin/service mysqld reload

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.