Linux installation and configuration MySQL environment

Source: Internet
Author: User
Tags check character

For the CentOS system, these kits can be installed in advance:

# yum-y Install GCC Libxml2-dev Curl screen \libpng12-dev autoconf libpcre3-dev make bzip2 \libevent-dev patch libjpeg62- Dev Libcurl4-openssl-dev \libfreetype6-dev g++ libtool libncurses5-dev psmisc Lrzsz

The following are some of the issues that need to be addressed in advance:

1. All downloaded files will be saved in the/usr/local/software/directory

2. MySQL will run as a MySQL user and will be added to the service boot Autorun

3. mysql will be installed in the/usr/local/mysql/directory

4. mysql default installation using the UTF8 character set

5. mysql data and log files are stored in the/var/mysql/corresponding directory

6. mysql configuration file is saved in/VAR/MYSQL/MY.CNF

First, Prepare:

# wget http://mysql.he.net/Downloads/MySQL-5.5/mysql-5.5.23.tar.gz# wget http://www.cmake.org/files/v2.8/ cmake-2.8.8.tar.gz# wget http://ftp.gnu.org/gnu/bison/bison-2.5.tar.gz

Ii. installation of CMake and bison

First, you can see if CMake # Rpm-qa |grep CMake is installed under

# cd/usr/local/software# Tar zxvf cmake-2.8.8.tar.gz
# CD cmake-2.8.8
#./bootstrap
# Make && make install
Install Bison:
# tar ZXVF bison-2.5.tar.gz
# CD bison-2.5
#./configure
# Make && make install

To create a MySQL user and user group:

# Groupadd mysql# useradd-r-g MySQL MySQL

Third, compile and install MySQL 5.5.23

# tar XVF mysql-5.5.23.tar.gz
# CD MYSQL-5.5.23/
# cmake-dcmake_install_prefix=/usr/local/mysql \
#-dmysql_unix_addr=/tmp/mysql.sock \
#-ddefault_charset=utf8 \
#-DDEFAULT_COLLATION=UTF8_GENERAL_CI \
#-DWITH_EXTRA_CHARSETS:STRING=UTF8,GBK \
#-dwith_myisam_storage_engine=1 \
#-dwith_innobase_storage_engine=1 \
#-dwith_readline=1 \
#-denabled_local_infile=1 \
#-dmysql_datadir=/var/mysql/data Next, install: # make && make install

Precautions:

When you recompile, you need to clear the old object file and cache information.

# make clean# rm-f cmakecache.txt# rm-rf/etc/my.cnf

Parameter description:

-dcmake_install_prefix=/usr/local/mysql//installation directory

-dinstall_datadir=/usr/local/mysql/data//Database storage directory

-ddefault_charset=utf8//using UTF8 characters

-DDEFAULT_COLLATION=UTF8_GENERAL_CI//Check character

-dextra_charsets=all//Install all extended character sets

-denabled_local_infile=1//Allow import of data from local

Assigning permissions:

# chmod +w/usr/local/mysql# chown-r mysql:mysql/usr/local/mysql# ln-s/usr/local/mysql/lib/libmysqlclient.so.16 #/usr /lib/libmysqlclient.so.16

Create the appropriate directory:

# mkdir-p/var/mysql/# mkdir-p/var/mysql/data/# mkdir-p/var/mysql/log/
# chown-r mysql:mysql/var/mysql/# CD support-files/

# CP MY-LARGE.CNF/VAR/MYSQL/MY.CNF (Note: my-large.cnf suitable for 1G memory of the server, you can choose according to their own configuration my-large.cnf or my-huge.cnf different configurations)

# CP Mysql.server/etc/init.d/mysqld

Four, configure the start MySQL:

1. If necessary, modify the configuration of MySQL first my.cnf

# VI/VAR/MYSQL/MY.CNF

2. mysql initialization installation

#/usr/local/mysql/scripts/mysql_install_db--DEFAULTS-FILE=/VAR/MYSQL/MY.CNF--basedir=/usr/local/mysql--datadir =/var/mysql/data--user=mysql

3. Add MySQL to boot

chmod +x/etc/init.d/mysqldvi/etc/init.d/mysqld (edit this file to find and modify the following variable contents:) basedir=/usr/local/mysqldatadir=/var/mysql/ Datachkconfig--add mysqldchkconfig--level 345 mysqld on

4. Start MySQL

# service Mysqld Start

If it already appears, starting MySQL ... Determine

The installation is now successful!

Linux installation and configuration MySQL environment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.