Home >Database >Mysql Tutorial >Detailed introduction on how to use rpm package to install MySQL on CentOS7
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 MariaDBCentOS7 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 mariadbCheck the installed MariaDB related yum package. The package name needs to be judged based on the result of the
rpm command.
yum list mariadb-libsRemove 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-libsDownload MySQL rpm packageSince 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.tarUse rpm package to install MySQLThe 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.rpmAfter 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.tarChange MySQL initial passwordThe following steps require root permissions.
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>
service mysqld restart
mysql
use mysql; UPDATE user SET authentication_string = password('your-password') WHERE host = 'localhost' AND user = 'root'; quit;
/etc/my.cnfDelete the previous
Addthat lineskip-grant-tables, and restart MySQL. This step is very important, failure to perform it may lead to serious
security issues.
mysql -u root -p
ALTER USER root@localhost IDENTIFIED BY 'your-new-password';
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!