Installation tutorial of the latest stable version of mysql 5.7. 17 under linux

  • 2021-07-03 00:58:14
  • OfStack

Install the latest stable version of mysql: mysql-5. 7.17 on linux from source code
In order to facilitate the installation process without being affected by boost dependence, download mysql-boost-5. 7.17. tar. gz version directly from official website. (The official explanation is that boost is needed during compilation, but it is not actually used.)

Installation directory:

Launch script:/etc/init. d/mysqld
Program Root Directory:/usr/local/mysql
Data catalog:/data/mysql

Installation process

1. Install dependencies


#yum install -y cmake gcc-c++* make ncurses-devel

2. Create an mysql user


#groupadd mysql
#useradd -r -g mysql -s /bin/false mysql

3. Download mysql-boost-5. 7.17. tar. gz and upload it to the server


#tar xzf mysql-5.7.17.tar.gz 
#cd mysql-5.7.17
#mkdir bld
#cd bld/
#cmake .. -DWITH_BOOST=../boost/ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql 

# After specifying parameters here, it reduces a lot of operations in the later startup process 
#make
#make install
# Use the default configuration file 
#cd /usr/local/mysql/support-files
#cp my-default.cnf ../my.cnf

# Error during compilation, clear temporary file and recompile: 
#make clean
#rm CMakeCache.txt

4. Add the executable path to the system environment variable after installation:

Environment variable


#echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
#source /etc/profile

5. Initialize the database


#mkdir /data/mysql
#chown -R mysql.mysql /data/mysql
#mysqld --defaults-file=/usr/local/mysql/my.cnf --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/mysql/

mysql5.7 will randomly generate a password after initialization, which will be directly hit on the screen.

Step 6 Start
Copy startup script:


#cd /usr/local/mysql/support-files
#cp mysql.server /etc/init.d/mysql

Direct startup


#mysqld_safe --user=mysql &
 Or 
#/etc/init.d/mysqld start

After starting, call the security script to realize: change the root password, delete the test library, and prohibit root remote login


#mysql_secure_installation

Partial configuration (not optimized)


[client]
port=3306
socket=/tmp/mysql.sock
character_set_client= utf8
[mysqld]
basedir = /usr/local/mysql
datadir = /data/mysql
port = 3306
socket = /tmp/mysql.sock
character-set-server = utf8
read_buffer_size=131072
#innodb
innodb_data_file_path=ibdata1:100M:autoextend
#binlog
server_id=1
log-bin=mysql-bin
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqldump]
quick
max_allowed_packet=32M
[mysql]
[myisamchk]

Related articles: