MySQL 5.7 Installation

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.