Install mysql5.7.33 from source code under Linux

1. Change the default source of the system to Tsinghua yum source

yum install -y wget 
wget http://mirrors.aliyun.com/repo/Centos-7.repo   
yum clean all
yum makecache

Install mysql5.7.33 from source code under Linux

2. Install dependencies required for compilation

yum -y install make gcc gcc-c++ cmake bison-devel ncurses ncurses-devel openssl-devel bison

3. Create users and groups

groupadd mysql
useradd -g mysql mysql

4. Create installation directory and data directory

mkdir -p /usr/local/mysql
mkdir -p /data/mysql

5. The authorized directory is mysql user and group

chown -R mysql.mysql /usr/local/mysql
chown -R mysql.mysql /data/mysql

6. Boost is required when compiling the following. Here first install boost (if you have boost, you don't need to install it)

mkdir -p /usr/local/boost
wget http://www.sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
解压
tar -xvzf boost_1_59_0.tar.gz

7. Download the mysql5.7 source code package:

cd /mnt
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.33.tar.gz
tar -xvzf  mysql-5.7.33.tar.gz
预编译:
cmake  .  -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ \
-DWITH_BOOST=/usr/local/boost \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DMYSQL_DATADIR=/data/mysql \
-DSYSCONFDIR=/etc \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306 \
-DWITH_XTRADB_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EXTRA_CHARSETS=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DWITH_BIG_TABLES=1 \
-DWITH_DEBUG=0

MYSQL源码安装参数详解

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql     Cmake预编译;
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock                          MYSQL Socket通信文件位置;
-DMYSQL_DATADIR=/data/mysql                                         MYSQL数据存放路径;
-DSYSCONFDIR=/etc                                                           配置文件路径; 
-DMYSQL_USER=mysql                                                      MYSQL运行用户;  
-DMYSQL_TCP_PORT=3306                                               MYSQL监听端口;
-DWITH_XTRADB_STORAGE_ENGINE=1                        开启xtradb引擎支持;
-DWITH_INNOBASE_STORAGE_ENGINE=1                       开启innodb引擎支持;
-DWITH_PARTITION_STORAGE_ENGINE=1                     开启partition引擎支持;
-DWITH_BLACKHOLE_STORAGE_ENGINE=1                     开启blackhole引擎支持;
-DWITH_MYISAM_STORAGE_ENGINE=1                         开启MyISAM引擎支持;
-DWITH_READLINE=1                                                          启用快捷键功能; 
-DENABLED_LOCAL_INFILE=1                                            允许从本地导入数据;
-DWITH_EXTRA_CHARSETS=1                                            支持额外的字符集;    
-DDEFAULT_CHARSET=utf8                                               默认字符集UTF-8;    
-DDEFAULT_COLLATION=utf8_general_ci                             检验字符;   
-DEXTRA_CHARSETS=all                                                      安装所有扩展字符集;
-DWITH_BIG_TABLES=1                                                         将临时表存储在磁盘上;
-DWITH_DEBUG=0                                                                禁止调试模式支持; 
make                                                                                          编译;   
make install                                                                                安装。

8. Compile and install

make && make install

Install mysql5.7.33 from source code under Linux

9. The default configuration file is /etc/my.cnf

10. Initialize the mysql database

cd /usr/local/mysql
./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/

Install mysql5.7.33 from source code under Linux
11. Add environment variables

echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
让配置理立即生效生效
source /etc/profile

12. Copy the mysql startup file to the /init/ startup directory

cp support-files/mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql

13, start the mysql database

service mysql restart

Install mysql5.7.33 from source code under Linux
14. Add startup service and set startup to start

chkconfig --add /etc/init.d/mysqld
chkconfig mysqld on

Guess you like

Origin blog.51cto.com/11353391/2668445