Linux installation and configuration of mysql environment

Centos system, you can install these toolkits 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 installation points need to be explained in advance:

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

2. mysql will run as the mysql user, and will be added to service starts automatically

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

4. mysql default installation uses utf8 character set

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

6. mysql The configuration file is saved in /var/mysql/my.cnf

1. Preparation:

# 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

2. Install cmake and bison

First, you can check whether cmake is installed # rpm -qa |grep cmake

# 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

Create mysql user and user group:

# groupadd mysql
# useradd -r -g mysql mysql

Third, compile and install MySQL 5.5.23


copy code
# 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

Copy code

Note :

When recompiling, you need to clear old object files 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 //Use utf8 characters

-DDEFAULT_COLLATION=utf8_general_ci //Check character

-DEXTRA_CHARSETS=all //Install all extended character sets

-DENABLED_LOCAL_INFILE=1 //Allow data to be imported from local

Assign 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 corresponding 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 is suitable for servers with about 1G memory, you can choose different configurations such as my-large.cnf or my-huge.cnf according to your own configuration)

# cp mysql.server /etc/init.d/mysqld

4. Configuration startup MySQL:

1. If necessary, please modify the mysql configuration my.cnf first

# vi /var/mysql/my.cnf

2. mysql initial 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/mysqld
vi /etc/init.d/mysqld (edit this file , find and modify the following variables:)
basedir=/usr/local/mysql
datadir=/var/mysql/data
chkconfig --add mysqld
chkconfig --level 345 mysqld on


4. Start mysql

# service mysqld start

If it already appears, Starting MySQL...[OK]

So far, the installation is successful!

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326899663&siteId=291194637