Install mysql5.7 under Linux

Original text: http://baijiahao.baidu.com/s?id=1584072431498789934&wfr=spider&for=pc

1. Download the MySQL5.7 installation package on the official website: mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz.

Download address: https://dev.mysql.com/downloads/mysql/

2. Remotely access CentOS7 through SSH Secure Shell Client

3. Uninstall the Mariadb database that comes with the system

4. Create mysql user group and mysql user

5. Upload the MySQL installation package to the CentOS7 server /root directory and extract it

# tar xzvf /root/mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz

6. Move the decompressed installation package to the directory under /data and rename it to mysql

# mv /root/mysql-5.7.20-linux-glibc2.12-x86_64 /data/mysql

The result is as follows

7. Modify permissions

8. Create the data directory as the database storage location

# mkdir /data/mysql/data

9. Initialize mysql

10. Start MySQL and see if it has been started successfully

11. Log in to MySQL with the initial password and change the password

12. Shut down the MySQL service and see if the shutdown is successful

13. Set the boot to start automatically

In the future, you can use the service command to control the start and stop of mysql. The commands are: service mysqld start and service mysqld stop. It is possible that an error will be reported during execution, as shown in the following figure

This is because mysql is installed in the /usr/local directory by default. If it is installed in the /usr/local directory, it will start and close normally, and no error will be reported. However, this time it is installed in the custom /data directory. At this time, you need to modify the /etc/init.d/mysqld file, save it and exit

Then execute the service mysqld start startup command, OK

Then execute the service mysqld stop shutdown command, OK

14. Configure global environment variables

Edit /etc/profile file

# vi /etc/profile

Add the following two lines of configuration at the bottom of the profile file, save and exit

PATH=/data/mysql/bin:/data/mysql/lib:$PATH

export PATH

Setting environment variables takes effect immediately

# source /etc/profile

15. Set up remote host login

Remote login failed

Check if port 3306 is open

# netstat -nupl|grep 3306

Open port 3306 and restart the firewall

Remote login again, success

Guess you like

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