1. Download the MySQL 5.7 binaries installation package
Mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
2. Extract it
Unzip mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
TAR-XF Mysql-5.7.19-linux-glibc2.12-x86_64.tar
3. Create MySQL users and user groups
Groupadd MySQL
Useradd mysql-g MySQL
4. Create a soft link to the MySQL directory.
Ln-s/opt/mysql/mysql-5.7.19-linux-glibc2.12-x86_64/usr/local/mysql
Chown-r Mysql:mysql/usr/local/mysql
5. Modifying environment variables
Export path= $PATH:/usr/local/mysql/bin
. /root/.bash_profile
6. Import MySQL config file my.cnf, to/etc directory, modify port and DataDir
7. Check the installation package
LDD MySQL
8. Initialize MySQL, config file default to use/ETC/MY.CNF
/usr/local/mysql/bin/mysqld--initialize
9. Find the root password
To the MySQL DataDir directory there is a error.log,grep password
10. Start MySQL
/usr/local/mysql/bin/mysqld &
11. Change the root password
Alter user user () identified by ' xxx ';
Simply wrote a Python installation script
#!/usr/bin/env python
Import OS
Mysql_dir=raw_input ("set MySQL dir \ n")
Os.system (' Groupadd MySQL ')
Os.system (' useradd mysql-g MySQL ')
# #print (Mysql_dir)
Os.system (' ln-s%s/usr/local/mysql '% (mysql_dir))
Os.system (' Chown-r mysql:mysql/usr/local/mysql ')
Profile=open ('/root/.bash_profile ', ' a ')
Profile.write (' path= $PATH:/usr/local/mysql/bin \ n ')
Profile.close ()
# #os. System (' Cat/root/.bash_profile ')
# #os. environ[' PATH ')
Print Os.system ('/usr/local/mysql/bin/mysql ')
Port=raw_input (' Set MySQL port \ n ')
Os.system (' sed-i \ ' s/^port=.*/port=%s/g\ '/etc/my.cnf '%port)
Os.system (' sed-i \ ' s/^datadir=.*/datadir=/data/mysql/%s/g\ '/etc/my.cnf '%port)
# #my_cnf =open ('/etc/my.cnf ', ' a ')
# #my_cnf. Write (' port= ' +port+ ' \ n ')
# #my_cnf. Write (' datadir=/data/mysql/%s '% (port))
# #my_cnf. Close ()
Os.system (' mkdir-p/data/mysql/%s '% (port))
Os.system (' chown-r mysql:mysql/data/mysql/%s '% (port))
Os.system ('/usr/local/mysql/bin/mysqld--initialize ')
Print (' MySQL password ')
Os.system (' cat/data/mysql/%s/error.log | grep password | awk \ ' {print $NF}\ '% (port)
Os.system ('/usr/local/mysql/bin/mysqld & ')
MySQL 5.7 Installation