Work often need to install mysql, each time the installation, always use a different method to install, there is a mistake to solve the problem, today again installed mysql, record the process, later use this way to install!
1. View the system version
[root@test107vm14 rpm-gpg]# lsb_release -a LSB Version: : the core - 4.1 - amd64: core - 4.1 - noarch: CXX - 4.1 - amd64: CXX - 4.1 - noarch: desktop - 4.1 - amd64: desktop - 4.1 - noarch: languages - 4.1 - amd64: la Nguages-4.1-noarch: Print-4.1-AMD64: Print-4.1-Noarch Distributor ID: CentOS Description: CentOS Linux release 7.3.1611 (Core) release: 7.3.1611 Codename: CoreCopy the code
Download the mysql installation package
Download address:Dev.mysql.com/downloads/m…Select the mysql version you want to download and the corresponding system version
RPM 5.6.41-1.el7.x86_64. RPM -bundle.tar: RPM 5.6.41-1.el7.x86_64. RPM -bundle.tar: RPM 5.6.41-1.el7.x86_64. RPM -bundle.tar: RPM 5.6.41-1.el7.x86_64.
3, check whether mysql already exists, if there is uninstallation, avoid some errors during installation!
rpm -qa | grep -i mysql
Copy the code
If yes, run the RPM -e packname –nodeps command to delete the installation package
which mysql
Copy the code
Delete the mysql configuration file.
Delete a mysql user.
userdel mysql
Copy the code
4. Upload the installation package
Upload the downloaded installation package to the appropriate directory, I upload to the /usr/local/mysql directory
mkdir -p /usr/local/mysql
Copy the code
Uploading the Installation Package
5. Decompress the installation package
Tar XVF MySQL - 5.6.41-1. El7. X86_64. RPM - bundle. The tarCopy the code
After decompression, the following files are obtained
6. Create a mysql user and group
groupadd -g 1000 mysql
Copy the code
useradd mysql -g mysql -p mysql
Copy the code
7, Install mysql
RPM -- the ivh MySQL server - 5.6.41-1. El7. X86_64. RPMCopy the code
Error message:
Conflicts with file from package Mariadb-libs-1:5.5.56-2.el7.x86_64Copy the code
Conflict with Mariadb, delete mariadb.
The RPM -e mariadb - libs - 1:5. 5.56-2. El7. X86_64 -- nodepsCopy the code
Then re-execute the install command above!
RPM - the ivh MySQL - the client - 5.6.41-1. El7. X86_64. RPMCopy the code
RPM - the ivh MySQL - devel - 5.6.41-1. El7. X86_64. RPMCopy the code
RPM - the ivh MySQL - Shared - 5.6.41-1. El7. X86_64. RPMCopy the code
Install these four, so the installation is complete!
8. Start mysql
service mysql start
Copy the code
After the startup is successful, you can check whether port 3306 is listened
9. Log in to mysql with a random password
find / -name .mysql_secret
Copy the code
Find the generated random password path, view this file to obtain the random password
Log in to mysql using the random default password
mysql -u root -p
Copy the code
10. Change the password
After a successful login, change the password. Otherwise, you cannot select the database to perform operations
SET PASSWORD=password('password');
Copy the code
FLUSH PRIVILEGES;
Copy the code
At this point, you are ready to perform mysql operations;