Operating system: rhel7.2
MySQL version: 5.7.11
1. mysql Download
http://dev.mysql.com/downloads/
2. Upload the MySQL software to the operating system
[Email protected] ~]# ls-l mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz-rw-r--r--. 1 root root 548193637 Dec 4 21:16 mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz
3. Add MySQL Users and groups
[[email protected] ~]# groupadd mysql[[email protected] ~]# useradd-r-G mysql-s/bin/false Mysql[[email protected] ~]# ID mysqluid=996 (mysql) gid=1000 (MySQL) groups=1000 (MySQL)
4. Create directory, change group and extract files
[[email protected] ~]# mkdir -p /opt/mysql/[[email protected] ~]# Mkdir /mysqldata[[email protected] ~]# mv /root/mysql-5.7.11-linux-glibc2.5-x86_64. tar.gz /opt/mysql/[[email protected] ~]# cd /opt/mysql/[[email protected] mysql]# lsmysql-5.7.11-linux-glibc2.5-x86_64.tar.gz[[email protected] mysql]# tar - zxvf mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz [[Email protected] mysql]# mv mysql-5.7.11-linux-glibc2.5-x86_64 mysql5.7.11[[email protected] mysql]# ls -ltotal 535352drwxr-xr-x. 9 7161 wheel 4096 feb 2 2016 mysql5.7.11-rw-r--r--. 1 root root 548193637 Dec 4 21:16 Mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz[[email protected] mysql]# chown mysql:mysql -r /opt/mysql/[[email protected] mysql]# chown mysql:mysql -r / mysqldata/
5, Initialize library
[[email protected] mysql]# cd mysql5.7.11/[[email protected] mysql5.7.11]# ./bin/mysqld --initialize --user=mysql --basedir=/opt/mysql/mysql5.7.11/ --datadir=/ mysqldata/2016-12-04t13:33:01.318081z 0 [warning] timestamp with implicit default value is deprecated. please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2016-12-04T13:33:01.729086Z 0 [warning] innodb: new log files created, lsn=457902016-12-04t13 :33:02.027182z 0 [warning] innodb: creating foreign key constraint System tables.2016-12-04t13:33:02.111882z 0 [warning] no existing uuid has been found, so we assume that this is the first time that this server has been started. generating a new uuid: 2dca0cf3-ba26-11e6-b4ff-080027e818bc.2016-12-04t13:33:02.118970z 0 [warning] gtid table is not ready to be used. Table ' mysql.gtid_executed ' cannot be opened.2016-12-04T13:33:02.120080Z 1 [Note] A temporary password is generated for [email protected]: rqwpw!9ineep[[email protected] Mysql5.7.11]# ls /mysqldata/auto.cnf ib_buffer_pool ibdata1 ib_ Logfile0 ib_logfile1 mysql performance_schema sys
Note: The initial password for root has been given in the log: Rqwpw!9ineep
Initialize the library with bin/mysql_install_db--user=mysql in versions prior to 5.7.6.
6. Start MySQL Database
#替换系统自带的my. cnf file [[email protected] mysql5.7.11]# mv /etc/my.cnf /etc/my.cnf.bak[[ email protected] mysql5.7.11]# cp support-files/my-default.cnf /etc/my.cnf# Add the following two [[email protected] mysql5.7.11]# vi /etc/my.cnfbasedir = /opt/] in my.cnf. mysql/mysql5.7.11datadir = /mysqldata# Start mysql[[email protected] mysql5.7.11]# ./bin/ mysqld_safe --user=mysql &[1] 1756[[email protected] mysql5.7.11]# 2016-12-04t13:44:30.046089z mysqld_safe logging to '/mysqldata/rhel7.err '. 2016-12-04T13 :44:30.097978z mysqld_safe starting mysqld daemon with databases from /mysqldata[[email protected] mysql5.7.11]# ps -ef |grep mysqlroot 1756 1182 0 21:44 pts/0 00:00:00 /bin/sh ./bin/mysqld_safe --user=mysqlmysql 1876 1756 1 21:44 pts/0 00:00:00 /opt/mysql/mysql5.7.11/bin/mysqld --basedir=/opt/mysql/mysql5.7.11 - -datadir=/mysqldata --plugin-dir=/opt/mysql/mysql5.7.11/lib/plugin --user=mysql --log-error=/ mysqldata/rhel7.err --pid-file=/mysqldata/rhel7.pidroot 1905 1182 0 21:44 pts/0 00:00:00 grep --color=auto mysql
7. Log in to MySQL, log in with the password when installing and change the root password
[[email protected] mysql5.7.11]# ./bin/mysql -uroot -p enter password: welcome to the mysql monitor. commands end with ; or \g.Your MySQL connection id is 2Server version: 5.7.11copyright (c) 2000, 2016, oracle and/or its affiliates. all rights reserved. oracle is a registered trademark of oracle corporation and/or Itsaffiliates. other names may be trademarks of their respectiveowners . type ' help; ' or ' \h ' for help. Type ' \c ' to clear the current input statement.mysql> set password= ' 1qaz! QAZ '; query ok, 0 rows affected (0.01 sec)
Note: Before 5.6, use Set Password=password (' NewPassword ') to change the password, the 5.7 version is no longer recommended to change the password, there will be the following prompt:
Mysql> set password=password (' 123456 '); query ok, 0 rows affected, 1 warning (0.00 sec) mysql> show warnings;+---------+------+----------------------------------------------------------------------------- --------------------------------------------------------------------------------------+| level | Code | Message |+---------+------+------------------------------------------------------------------- ------------------------------------------------------------------------------------------------+| warning | 1287 | ' Set password = password (' <plaintext_password> ') ' is deprecated and will be removed in a future release. Please use SET PASSWORD = ' <plaintext_password> ' instead |+---- -----+------+-------------------------------------------------------------------------------------------------- -----------------------------------------------------------------+1 row in set (0.00&NBSP;SEC)
To this, the MySQL5.7.11 installation is complete.
Official Document: Http://dev.mysql.com/doc/refman/5.7/en/binary-installation.html
This article is from the "DBA fighting!" blog, so be sure to keep this source http://hbxztc.blog.51cto.com/1587495/1879396
RHEL 7.2 installs MySQL 5.7.112 in-plate