Brief introduction
MySQL is a relational database management system developed by the Swedish MySQL AB company and is currently part of Oracle's product portfolio. MySQL is one of the most popular relational database management systems, MySQL is the best relational database management system application software in Web application. MySQL is a relational database management system, where relational databases store data in different tables rather than putting all of the data in a large warehouse, which increases speed and increases flexibility. The SQL language used by MySQL is the most commonly used standardized language for accessing databases. MySQL software has adopted a dual licensing policy, divided into community and commercial version, due to its small size, fast, low total cost of ownership, especially the open source, the development of the general small and medium-sized web site to choose MySQL as the site database.
Experimental environment
System Environment: centos7.4
Server IP Address: 192.168.100.71
Yum Mount directory:/mnt/sr0
Related source package: Baidu Cloud Download Password: r26y
Build Step 1, add a new hard drive as an extract directory
[Email protected]_5 ~]# Fdisk/dev/sdb
[[Email protected]_5 ~]# mkfs.ext4/dev/sdb1 #格式化分区, writing system files
[Email protected]_5 ~]# mount/dev/sdb1/opt/#挂载至解压目录下
[Email protected]_5 ~]# df-h
2. Install dependent packages
[Email protected]_5 ~]# mount/dev/sr0/mnt/sr0/#挂在光盘
[[Email protected]_1 ~]# yum-y install \
ncurses \
Ncurses-devel \
Bison \
CMake
3. Create process User
[[Email protected]_1 ~]# useradd-s/sbin/nologin MySQL
4, unzip the corresponding source package
[Email protected]_1 ~]# tar zxvf mysql-5.7.17.tar.gz-c/opt/
[Email protected]_1 ~]# tar zxvf boost_1_59_0.tar.gz-c/usr/local/
[Email protected]_1 ~]# cd/usr/local/
[[Email protected]_1 local]# MV Boost_1_59_0 boost
5. Install MySQL
[Email protected]_1 ~]# cd/opt/mysql-5.7.17/
[email protected]_1 ~]# cmake \
-dcmake_install_prefix=/usr/local/mysql \
-dmysql_unix_addr=/usr/local/mysql/mysql.sock \
-DSYSCONFDIR=/ETC \
-dsystemd_pid_dir=/usr/local/mysql \
-ddefault_charset=utf8 \
-DDEFAULT_COLLATION=UTF8_GENERAL_CI \
-dwith_innobase_storage_engine=1 \
-dwith_archive_storage_engine=1 \
-dwith_blackhole_storage_engine=1 \
-dwith_perfschema_storage_engine=1 \
-dmysql_datadir=/usr/local/mysql/data \
-dwith_boost=/usr/local/boost \
-dwith_systemd=1
Note: If there is an error in the process of CMake, when the error is resolved, it is necessary to remove the CMakeCache.txt file from the source directory and then CMake again, otherwise the errors will remain
[[Email protected]_1 mysql-5.7.17]# make && do install #时间稍慢, wait ...
6. Modify MySQL Permissions
[Email protected]_1 ~]# chown-r mysql:mysql/usr/local/mysql/
7. Edit the master configuration file
[Email protected]_1 ~]# vim/etc/my.cnf
Recommendation: You can delete the contents of the configuration file and copy the following directly [client]
Port = 3306
Default-character-set=utf8
Socket =/usr/local/mysql/mysql.sock
[MySQL]
Port = 3306
Default-character-set=utf8
Socket =/usr/local/mysql/mysql.sock
[Mysqld]
user = MySQL
Basedir =/usr/local/mysql
DataDir =/usr/local/mysql/data
Port = 3306
Character_set_server=utf8
Pid-file =/usr/local/mysql/mysqld.pid
Socket =/usr/local/mysql/mysql.sock
Server-id = 1
Sql_mode=no_engine_substitution,strict_trans_tables,no_auto_create_user,no_auto_value_on_zero,no_zero_in_date, No_zero_date,error_for_division_by_zero,pipes_as_concat,ansi_quotes
[Mysqld_safe]
Log-error=/var/log/mariadb/mariadb.log
Pid-file=/var/run/mariadb/mariadb.pid
#
# include all files from the Config directory
#
!includedir/etc/my.cnf.d
8. Related optimization
[Email protected]_1 ~]# chown mysql:mysql/etc/my.cnf
[Email protected]_1 ~]# echo ' path=/usr/local/mysql/bin:/usr/local/mysql/lib: $PATH ' >>/etc/profile
[Email protected]_1 ~]# echo ' export PATH ' >>/etc/profile
[Email protected]_1 ~]# source/etc/profile
9. Initialization Service
[Email protected]_1 ~]# cd/usr/local/mysql/
[email protected]_1 mysql]# bin/mysqld \
--initialize-insecure \
--user=mysql \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data
10. Start the service
[Email protected]_1 ~]# cp/usr/local/mysql/usr/lib/systemd/system/mysqld.service/usr/lib/systemd/system/
[Email protected]_1 ~]# systemctl daemon-reload
[Email protected]_1 ~]# systemctl start mysqld
[[Email protected]_1 ~]# systemctl Enable mysqld
[[Email protected]_1 ~]# NETSTAT-ANPT | grep 3306
11. Log in to MySQL
[Email protected]_1 ~]# mysqladmin-u root-p password ' 123 '
[Email protected]_1 ~]# mysql-u root-p123
CetOS7.4 Manually compiled installation mysql-5.7.17 (with source package)