Home >Database >Mysql Tutorial >Detailed introduction on how to use rpm package to install MySQL on CentOS7

Detailed introduction on how to use rpm package to install MySQL on CentOS7

黄舟
黄舟Original
2017-06-04 11:58:541998browse

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 mode.

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.

View the installed MariaDB related rpm packages.

rpm -qa | grep mariadb

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

Remove the installed MariaDB related yum package. The package name needs to be judged based on the result of the

yum list command. This step requires root privileges.

yum remove mariadb-libs

Download MySQL rpm package

Since the software package is very 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.

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

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

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

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 login permissions test. Add a line:

    <p style="margin-bottom: 7px;">skip-grant-tables<br/></p>

  2. Restart MySQL.

    service mysqld restart

  3. Log in to MySQL without a password.

    mysql

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

    use mysql;
    UPDATE user SET authentication_string = password(&#39;your-password&#39;) WHERE host = &#39;localhost&#39; AND user = &#39;root&#39;;
    quit;

  5. Modify the configuration file

    /etc/my.cnfDelete the previousAddthat 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

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

    ALTER USER root@localhost IDENTIFIED BY &#39;your-new-password&#39;;

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 on CentOS7. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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