Compile and install mysql5.7 in centos 7, centosmysql5.7
I. Installation conventions
Mysql installation path:/usr/local/mysql
Mysql database path: /data/mysql
My configuration file path: /usr/local/mysql/my.cnf
Ii. Uninstall mariadb
# Rpm-qa | grep mariadb # rpm-e -- nodeps mariadb-libs-5.5.37-1.el7_0.x86_64 package name is learned FROM THE PREVIOUS QUERY
3. create user groups and users
Add a mysql Groupgroupadd mysql
Add Useruseradd -g mysql mysql -s /bin/false
# Download the source code package
Download the latest version from the following URL on the official website:
Http://dev.mysql.com/downloads/mysql/5.7.html#downloads
Http://download.savannah.gnu.org/releases/libunwind/
Https://github.com/gperftools/gperftools/releases
# cd /usr/local/src/# wget http://download.savannah.gnu.org/releases/libunwind/libunwind-1.1.tar.gz# wget http://gperftools.googlecode.com/files/gperftools-2.5.tar.gz# wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.x.tar.gz
Libunwind Installation
# tar zxvf libunwind-1.1.tar.gz# cd libunwind-1.1# ./configure# make# make install
Install gperftools
# cd ..# tar zxvf gperftools-2.1.tar.gz# cd gperftools-2.1# ./configure# make# make install# echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf# ldconfig
Install mysql
# cd ..# tar zxvf mysql-5.7.x.tar.gz# cd mysql-5.7.x
Run the following command to view the compilation parameter description before Compilation:
# cmake . -LH | more
If an error is reported in the intermediate process, delete cmakecache.txt and re-compile it.
rm -rf CMakeCache.txt
Mysq compilation and Installation
# Cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql \-keys =/data/mysql \-DSYSCONFDIR =/etc \-DEXTRA_CHARSETS = all \-DDEFAULT_CHARSET = utf8 \-DDEFAULT_COLLATION = begin \-DWITH_INNOBASE_STORAGE_ENGINE = 1 \-DENABLED_LOCAL_INFILE = 1 \-DMYSQL_UNIX_ADDR =/dev/shm/mysql. sock \-DMYSQL_TCP_PORT = 3306 \-DMYSQL_USER = mysql \-DWITH_DEBUG = 0 \-DDOWNLOAD_BOOST = 1 \-DWITH_BOOST =/usr/local/boost # make install ''' change permission ''' # chmod 755/var/lib/mysql # cd/usr/local/mysql # chown-R mysql: mysql.
Initialize mysql
/usr/local/mysql/bin/mysqld --initialize --basedir=/usr/local/mysql --datadir=/data/mysql --user=mysql --explicit_defaults_for_timestamp=1
Create a mysql configuration file
# cp support-files/my-default.cnf /usr/local/mysql/my.cnf
Summary
The above is all about this article. I hope this article will help you in your study or work. If you have any questions, please leave a message.