November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

CentOS 7.2 install the MySQL 5.7.18 with the rpm package

Description

This article uses MySQL-5.7.18. The operating system is 64-bit CentOS Linux release 7.2.1511 (Core), installed as a desktop.

Uninstall MariaDB

CentOS7 defaults to installing MariaDB instead of MySQL, and the yum server also removes the MySQL-related packages. Because MariaDB and MySQL may conflict, so first uninstall MariaDB.

View the installed DebianDB related rpm package.

rpm -qa | grep mariadb
View the installed MariaDB-related yum package, package name to be rpmjudged by the results of the order.

yum list mariadb-libs
Remove the installed MariaDB-related yum package, the package name to yum listjudge the results according to the order. This step requires root privileges.

yum remove mariadb-libs
Download the MySQL rpm package

As the software package is large, you can first use other ways (such as Thunder) to download. Using rpm, but also can not be installed under the conditions of the network – this is yum can not do. To install other versions of MySQL, please go to the official website to search 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 the rpm package to install MySQL

The following steps require root privileges. And because of the dependencies between the packages, the rpmcommands must be executed in sequence.

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 the installation is successful, 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
Modify the MySQL initial password

The following steps require root privileges.

Since the beginning does not know the password, first modify the configuration file /etc/my.cnfso that MySQL skip the login when the permissions check. Add a line

skip-grant-tables
Restart MySQL.

service mysqld restart
Free password to log in to MySQL.

mysql
In the mysql client to execute the following order, modify the root password.

use mysql;
UPDATE user SET authentication_string = password(‘your-password’) WHERE host = ‘localhost’ AND user = ‘root’;
quit;
Modify the configuration file to /etc/my.cnfdelete the previous line skip-grant-tablesand restart MySQL. This step is very important and failure to perform can lead to serious security problems.
Log in using the password you just set.

mysql -u root -p
MySQL will force the need to re-modify the password, and can not be a simple rule password.

ALTER USER root@localhost IDENTIFIED BY ‘your-new-password’;
Steps may be a little trouble, have not yet thought of other ways, first use this.

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>