MySQL 5.7 installation configuration

1. Install and configure mysql5.7

1. Download the installation package

Download address: http://dev.mysql.com/downloads/mysql/#downloads

 

2. Check whether the library file exists and delete it if so

$ rpm -qa | grep -i mysql

$ rpm -e mysql-libs-x.x.x.x86_64 –nodeps

 

3. Check whether the mysql group and user exist, if any, delete

$ cat /etc/group | grep mysql

$ cat /etc/passwd | grep mysql

If so, execute the following command:

$ userdel mysql

$ groupdel mysql

If not, please execute the following command:

$ groupadd mysql

$ useradd -r -g mysql mysql

 

4. Unzip the TAR package and change the group and user it belongs to

$ cd /usr/local/

$ tar zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

$ mv mysql-5.7.17-linux-glibc2.5-x86_64 mysql

$ chown -R mysql mysql/

$ chgrp -R mysql mysql/

 

5. Add MySQL data, log temporary file directory and authorize 

$ mkdir -p /data/mysql/{data,tmp,logs}

$ cd / data /

$ chown -R mysql mysql/

$ chgrp -R mysql mysql/

$ ln -s /usr/local/mysql/mysql.sock /tmp/mysql.sock

 

6. Modify the configuration information

$ cd /usr/local/mysql

$ cp support-files/mysql.server /etc/init.d/mysqld

$ chmod 755 /etc/init.d/mysqld

$ cp support-files/my-default.cnf /etc/my.cnf

$ vi /etc/init.d/mysqld

 

7. Modify the startup script

$ vi /etc/init.d/mysqld

# mysql installation directory and data storage directory

basedir=/usr/local/mysql/

datadir=/data/mysql/data/

$ vi /etc/my.cnf

basedir = /usr/local/mysql

datadir = /data/mysql/data

port = 3306

server_id = 1

socket = /usr/local/mysql/mysql.sock

 

8. Add environment variables

$ export PATH=$PATH:/usr/local/mysql/bin

$ source /etc/profile

 

over!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326461377&siteId=291194637