Home > Database > Mysql Tutorial > body text

Detailed introduction on how to use rpm package to install mysql 5.7.18 in CentOS7

黄舟
Release: 2017-06-04 09:57:01
Original
1997 people have browsed it

This article mainly introduces in detail the steps related to installing CentOS7 using rpm package mysql 5.7.18. It has certain reference value. Interested friends can For reference,

Instructions

This article was written on 2017-05-20, using MySQL-5.7.18. The operating system is 64-bit CentOS Linux release 7.2.1511 (Core), installed in desktop form.

Uninstall MariaDB

CentOS7 installs MariaDB by default instead of MySQL, and MySQL-related software packages are also removed from the yum server. Because MariaDB and MySQL may conflict, uninstall MariaDB first.

1. Check the installed MariaDB related rpm packages.

rpm -qa | grep mariadb
Copy after login

2. Check the installed MariaDB related yum package. The package name needs to be judged based on the result of the rpm command.

yum list mariadb-libs
Copy after login

3. Remove the installed MariaDB related yum package. The package name needs to be determined based on the results of the yum list command. This step requires root privileges.

yum remove mariadb-libs
Copy after login

Download the MySQL rpm package

Since the software package is large, you can download it through other methods (such as Thunder) first. Using the rpm method, you can also install it without being able to connect to the Internet - this is something that yum cannot do. If you need to install other versions of MySQL, please go to the official website to search for the corresponding rpm download link.

Copy code The code is as follows:

wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar
Copy after login

Use rpm package to install MySQL

The following steps require root permissions. And due to the dependencies between packages, each rpm command must be executed in order.

mkdir mysql-5.7.18
tar -xv -f mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar -C mysql-5.7.18
cd mysql-5.7.18/
rpm -ivh mysql-community-common-5.7.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.18-1.el7.x86_64.rpm
Copy after login

After successful installation, you can also delete the installation files and temporary files.

cd ..
rm -rf mysql-5.7.18
rm mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar
Copy after login

Change MySQL initial password

The following steps require root permissions.

1. Since the password is not known at the beginning, first modify the configuration file /etc/my.cnf to make MySQL skip the permission check during login. Add a line:

skip-grant-tables
Copy after login

2. Restart MySQL.

service mysqld restart
Copy after login

3. Log in to MySQL without a password.

mysql
Copy after login

4. Execute the following command on the mysql client to change the root password.

use mysql;
UPDATE user SET authentication_string = password('your-password') WHERE host = 'localhost' AND user = 'root';
quit;
Copy after login

5. Modify the configuration file /etc/my.cnfDelete the previously added lineskip-grant-tables and restart MySQL. This step is very important, failure to perform it may lead to serious security issues.

6. Log in using the password you just set.

mysql -u root -p
Copy after login

7.MySQL will force you to change the password, and it cannot be a simple rule password.

ALTER USER root@localhost IDENTIFIED BY 'your-new-password';
Copy after login

The steps may be a little troublesome. I haven’t thought of other methods yet, so I will use them like this first.

The above is the detailed content of Detailed introduction on how to use rpm package to install mysql 5.7.18 in CentOS7. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template