1. Install yum repo
There is no mysql in the yum source of centos (you can try to use the installation command directly: Yum install mysql server). You need to download the yum repo configuration file on mysql's official website, and then install:
#download wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm #repo installation rpm -ivh mysql57-community-release-el7-9.noarch.rpm
2. Install mysql
yum install mysql-server #Installation command systemctl start mysqld #Start MySQL
3. Operation command set
#Install mysql for the first time and start the operation with notes systemctl start mysqld #Start MySQL. After the command is executed, there is no return. You can use the status command to check whether the startup is successful systemctl stop mysqld #Close MySQL systemctl restart mysqld #Restart MySQL #Check the running status of MySQL and display active (running) to indicate success systemctl status mysqld #Operation example [root@VM_0_6_centos ~]# systemctl status mysqld ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2019-03-18 11:25:45 CST; 56s ago systemctl enable mysqld #Set startup systemctl disable mysqld #Turn off startup #For the first installation, you need to obtain a temporary password. The command is as follows. The last colon returned is followed by the temporary password. Here I am: aMKsBq#s-2(Y grep 'temporary password' /var/log/mysqld.log #Operation example [root@VM_0_6_centos ~]# grep 'temporary password' /var/log/mysqld.log 2019-03-18T03:25:37.681423Z 1 [Note] A temporary password is generated for root@localhost: aMKsBq#s-2(Y #If not, delete the original mysql residual data first. Note: this operation is not required for the first installation rm -rf /var/lib/mysql #Restart after deletion systemctl restart mysqld #Restart MySQL #Command to log in to mysql. After input, prompt for password. The password is hidden and not displayed. Just copy it in directly. Press enter to log in successfully mysql -u root -p #Indicates root account login #Operation example: [root@VM_0_6_centos ~]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.25 Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> #After logging in, you can operate mysql database
4. Installation process problems
Because SSH tool will automatically break if you don't operate it for a long time. When you install mysql to half of the time, you need to select is this OK [y / N]: when you do y, you need to do other things, reopen the tool connection, and then use yum install mysql server to install the following content:
[root@VM_0_6_centos ~]# yum install mysql-server Loaded plugins: fastestmirror, langpacks Existing lock /var/run/yum.pid: another copy is running as pid 22795. Another app is currently holding the yum lock; waiting for it to exit... The other application is: yum Memory : 87 M RSS (482 MB VSZ) Started: Mon Mar 18 10:53:34 2019 - 25:01 ago State : Sleeping, pid: 22795
It shows that yum is locked. Solution: see the pid in the first line and kill it directly. Continue to install mysql5.7 normally
[root@VM_0_6_centos ~]# kill -9 22795