Configuration Instructions
Linux version: Centos7
MySQL version: MySQL5.7.16
This document is available for MySQL version >=5.7.6
First, uninstall CentOS7 the default carrying MARIADB package
# Check MARIADB installation Pack
[root@wing ~]# rpm-qa | grep-i mysql
[root@wing ~]# rpm-qa | grep-i mariadb
. 5.50-1.el7_2.x86_64
# Uninstall MARIADB installation package
[root@wing ~]# rpm-e
Error: Failed dependencies:
libmysqlclient.so.18 () (64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64
libmysqlclient.so.18 (libmysqlclient_18) (64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64
[ Root@wing ~]# rpm-e mariadb-libs-5.5.50-1.el7_2.x86_64 postfix-2:2.10.1-6.el7.x86_64
Ii. access to all versions of MySQL (5.0.15-latest) address portal
http://downloads.mysql.com/archives/community/
Third, the installation of compiling software
Yum install-y cmake make gcc gcc-c++
Four, create MySQL installation directory
# such as MySQL installation directory is:/usr/local/mysql
mkdir-p/usr/local/mysql
V. Extract the MySQL source package
TAR-ZXVF mysql-5.7.16.tar.gz
Vi. creating MySQL users and user groups
# Create user groups
Groupadd mysql
# create MySQL user, owning group for MySQL
useradd-s/bin/bash-m-g MySQL MySQL
Installation of MySQL dependent dependency pack
Yum install-y ncurses-devel openssl-devel bison-devel Libaio
Eight, boost library installation
# This step can be omitted, in the CMake phase to add parameters-ddownload_boost=1-dwith_boost=/usr/local/boost can be
# BOOST library installation
wget http:// sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
TAR-ZXVF boost_1_59_0.tar.gz-c/usr/ Local
mv/usr/local/boost_1_59_0/usr/local/boost
cd/usr/local/boost
./bootstrap.sh
./B2 Stage Threading=multi link=shared
./b2 Install Threading=multi link=shared
Nine, create MySQL related directory
| Catalog | meaning | Configuration Parameters |
| : ——— | ———————————— –| —————————————-|
| Bin_log | Binary Log Directory | Log_bin_basename
Log_bin_index |
| MyData | Data File Directory | DataDir |
| Innodb_log | InnoDB Redo Log Directory | Innodb_log_group_home_dir |
| Innodb_ts | InnoDB shared Table Space Directory | Innodb_data_home_dir |
| Log | Log file directory (Error log+general log+slow log) | Log_error
General_log_file
Slow_query_log_file |
| Relay_log | InnoDB Relay Log Directory | Relay_log_basename
Relay_log_index |
| Tmpdir | Temporary Files Directory | Tmpdir |
| Undo_log | InnoDB Rollback LOG Directory | Innodb_undo_directory |
Mkdir-p/data/mysql/mysql3306/bin_log
mkdir-p/data/mysql/mysql3306/db_file
mkdir-p/data/mysql/mysql3306 /innodb_log
mkdir-p/data/mysql/mysql3306/innodb_ts
mkdir-p/data/mysql/mysql3306/log
mkdir-p Mysql/mysql3306/relay_log
mkdir-p/data/mysql/mysql3306/tmpdir
mkdir-p/data/mysql/mysql3306/undo_log
X. Modify the directory created by step 9 to the user and the group to which they belong mysql:mysql
Chown-r mysql:mysql/data/mysql/mysql3306
Place the MySQL profile my.cnf in the/etc directory
By default, MySQL will sequentially find the following paths to obtain the MySQL configuration file:
/etc/my.cnf
/etc/mysql/my.cnf
/etc/my.cnf/my.cnf
/usr/local/mysql/my.cnf
~/.my.cnf
The configuration file can be specified by –defaults-file=xxx during use.
# Modify the MySQL profile to belong to the user and the group
chown-r Mysql:mysql my.cnf
Compile and install mysql5.7.6+
# Switch to the mysql-5.7.16 source directory
cd/path/mysql-5.7.16
# cmake
cmake-dcmake_build_type=relwithdebinfo-dcmake_ Install_prefix=/usr/local/mysql-dmysql_datadir=/data/mysql/mysql3306/mydata-dsysconfdir=/etc/my.cnf-dwith_ Innobase_storage_engine=1-dwith_partition_storage_engine=1-ddefault_charset=utf8-ddefault_collation=utf8_ General_ci-denable_debug_sync=0-denabled_local_infile=1-denabled_profiling=1-dmysql_tcp_port=3306-dmysql_unix_ Addr=/data/mysql/mysql3306/tmpdir/my-3306.sock-dwith_debug=0-dwith_ssl=yes-dwith_safemalloc=off-ddownload_ Boost=1-dwith_boost=/usr/local/boost
#
Make # This command allows you to specify multithreaded work by adding-j parameters, such as Make-j2 && make Install-j2 Use 2 CPU cores for make
# After this step is completed, you can go to the directory specified by the Cmake_install_prefix parameter, that is, under the MySQL installation directory to view the MySQL related directory and file make
&& Make install
# Modify the MySQL installation directory to the user and user group for Mysql:mysql
Chown-r mysql:mysql/usr/local/mysql
Initializing MySQL
"Shell
# into the MySQL installation directory under
cd/usr/local/mysql
# initialize MySQL, remember--defaults-file=/etc/ My.cnf to be placed in the first position of the parameter, initialization information can be viewed in the MySQL errorlog, and a random password of root is generated in errorlog, which is only for root@localhost users.
mysqld--defaults-file=/etc/my.cnf--initialize--basedir=/usr/local/mysql--datadir=/data/mysql/mysql3306/ MyData--user=mysql
1. Add MySQL environment variables
Vim/etc/profile
# under ~/.BASHRC file add the following statement
Export mysql_home=/usr/local/mysql
export path=${mysql_home}/ Bin: $PATH
# After saving, make environment variable effective
source/etc/profile
2. Start MySQL
Mysqld_safe--defaults-file=/etc/my.cnf &
# Now you can see the related process through Ps-ef | grep mysql
3. Login to MySQL
mysql-uroot-s/data/mysql/mysql3306/tmpdir/mysql.sock-p # Enter the random password generated in errorlog to login to MySQL #
Login MySQL need to modify the root password, otherwise the following conditions: Root@localhost: (none) 11:16:52> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before the this executing.
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before the this executing.
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before the this executing.
# Modify root password set password= ' MYSQL '; # The current version can use a direct string instead of the previous password (' xxx ') encryption method, the current version prompts as follows: Root@localhost: (none) 11:16:54> set Password=password (' MYSQL '
); Query OK, 0 rows affected, 1 Warning (0.00 sec) Warning (Code 1287): ' SET PASSWORD = PASSWORD (' <plaintext_password> ' ) ' is deprecated and'll be removed in a future release. Please use set PASSWORD = ' <plaintext_password> ' instead root@localhost: (none) 11:19:27> SET password= ' MYSQL '; /pre>
4. Close MySQL
Mysqladmin shutdown-uroot-s/data/mysql/mysql3306/tmpdir/mysql.sock-p
# using the new password
The mysql5.7.6+ of initialization differs from the MYSQL5.6.XX
The initial chemical industry has different
MYSQL5.6.XX is using the mysql_install_db,mysql5.7.6+ official recommendation to use Mysqld–initialize.
Initializing databases differently
There are mysql,information_schema,performance_schema,test four databases after initialization of MYSQL5.6.XX, mysql5.7.6+ after initialization mysql,information_ Schema,performance_schema,sys four databases.
Initialize user different
mysql5.6.xx root@localhost,root@ ':: 1 ', root@ ' hostname ', ' @ ' localhost ', ' @ ' hostname ' Five users, mysql5.7.6+ Mysql.sys,root@localhost User exists after initialization
Initialize root password
mysql5.6.xx the root password is null after initialization, mysql5.7.6+ Initializes a random password for the root@localhost user.
```
Summarize
The above is the entire content of this article, I hope the content of this article for everyone's study or work can bring certain help, if you have questions you can message exchange.