Home >Database >Mysql Tutorial >An introduction to how to use YUM to quickly install MySQL5.7 under Centos7.2

An introduction to how to use YUM to quickly install MySQL5.7 under Centos7.2

黄舟
黄舟Original
2017-06-18 10:41:571238browse

This article mainly introduces how to quickly install MySQL5.7 using YUM under Centos7.2. Friends who need it can refer to it

Uninstall the mariadb database that comes with the system


##

# rpm -qa| grep mariadb
# rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64

Download the YUM library


# rpm wgethttp://dev.MySQL.com/get/mysql57-community-release-el7-7.noarch.rpm

Install the YUM library


# rpm yum localinstall -ymysql57-community-release-el7-7.noarch.rpm

Install the database


# rpm yum install -y mysql-community-server

Start the MySQL service


# rpm systemctl start mysqld.service

Due to mysql5.7 will automatically generate a password, and the password file is stored in /var/log/mysqld.log

Search for the password keyword to find the password, log in to mysql


# mysql -uroot -p

Reset the root user password


mysql > alter user 'root'@'localhost' identified by '密码';

Just log in again as the root user and the password you just set. And authorize user root to connect to mysql server from any host using password


mysql > grant all privileges on *.* to 'root'@'%' identifiedby '密码' with grant option;
mysql > flush privileges;

or allow user root to connect to mysql server only from the host with ip 192.168.1.1


mysql > grant all privileges on *.* to 'root'@'192.168.1.1' identified by '密码' with grant option;
mysql > flush privileges;

Open port 3306


# firewall-cmd --add-port=3306/tcp

The above is the detailed content of An introduction to how to use YUM to quickly install MySQL5.7 under Centos7.2. 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