RHEL 上 MySQL安装与配置

来源:互联网 发布:淘宝流量和访客数 编辑:程序博客网 时间:2024/06/05 19:10


Redhat Enterprise Linux (RHEL) Install and Configure MySQL Database Server

by nixCraft onMarch 20, 2007 · last updated atJune 22, 2012

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

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               = 1query_cache_limit              = 1Mquery_cache_size               = 32M 

You can setup MyISAM buffer size and recover options:

 # For MyISAM #key_buffer_size                = 24Mmyisam_recover                 = FORCE,BACKUP 

Log slow queries for troubleshooting as follows:

 # LOGGING #log_queries_not_using_indexes  = 1slow_query_log                 = 1slow_query_log_file            = /var/lib/mysql/mysqld-slow-query.log 

Set caches and other limits as follows:

 tmp_table_size                 = 32Mmax_heap_table_size            = 32Mmax_connections                = 500thread_cache_size              = 50open_files_limit               = 65535table_definition_cache         = 4096table_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

原创粉丝点击