Home > Database > Mysql Tutorial > body text

How to use YUM to install MySQL5.6 under CentOS7

醉折花枝作酒筹
Release: 2021-05-08 10:48:01
forward
1592 people have browsed it

This article will introduce to you how to install MySQL5.6 using YUM under CentOS7. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

How to use YUM to install MySQL5.6 under CentOS7

rpm -qa | grep mysql
Copy after login

If a null value is returned, it means MySQL is not installed.

Note: In the new version of CentOS7, the default database has been updated to Mariadb instead of MySQL, so executing the yum install mysql command only updates the Mariadb database and does not install MySQL.

(2) Check the installed Mariadb database version.

rpm -qa|grep -i mariadb
Copy after login

# (3) Uninstall the installed Mariadb database.

rpm -qa|grep mariadb|xargs rpm -e --nodeps
Copy after login

(4) Check the installed Mariadb database version again to confirm whether the uninstallation is complete.

rpm -qa|grep -i mariadb
Copy after login

(5) Download the installation package file.

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
Copy after login

(6) Install the mysql-community-release-el7-5.noarch.rpm package

rpm -ivh mysql-community-release-el7-5.noarch.rpm
Copy after login

After the installation is completed, two yum source files, mysql-community.repo and mysql-community-source.repo, will be added to the /etc/yum.repos.d/ directory.

Execute the yum repolist all | grep mysql command to view the available mysql installation files.

(6) Install mysql.

yum install mysql-server
Copy after login

(7) Check whether mysql is installed successfully.

rpm -qa | grep mysql
Copy after login

(8) Start the mysql service.

systemctl start mysqld.service #启动 mysql
systemctl restart mysqld.service #重启 mysql
systemctl stop mysqld.service #停止 mysql
systemctl enable mysqld.service #设置 mysql 开机启动
Copy after login

Mysql common file path:

 /etc/my.cnf This is the main configuration file of mysql

 /var/lib/mysql mysql The database file storage location of the database

/var/logs/mysqld.log The database log output storage location

(9) Set the password.

After the installation of mysql5.6 is completed, the password of its root user is empty by default. We need to log in promptly with the root user of mysql (press enter directly for the first time without entering a password) and change the password.

# mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD("这里输入root用户密码") where User='root';
mysql> flush privileges;
Copy after login

(10) Set up remote host login

mysql> GRANT ALL PRIVILEGES ON *.* TO 'your username'@'%' IDENTIFIED BY 'your password';
Copy after login

Execute the following command to add remote login capability to the root user.

mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "123456";
Copy after login

[Recommended learning: SQL video tutorial]

The above is the detailed content of How to use YUM to install MySQL5.6 under CentOS7. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
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