We use yum to install, easy and happy!
In order to download MySQL later, we can change the default yum source of CentOS and replace it with Ali's.
# Take a look at the default yum source
cd /etc/yum.repos.d/&& ll
# Back up the original yum source
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
# Download the new CentOS-Base.repo to/etc/yum.repos.d/
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
# refresh cache
yum clean all && yum makecache
In order to install MySQL smoothly and prevent various conflicts, let's uninstall the old MySQL related (mariadb is also mysql).
yum list installed | grep mysql
yum list installed | grep maria
My centos7 shows as follows
mariadb-libs-5.5.40-1.el7_0.x86_64
yum -y remove mariadb-libs-5.5.35-3.el7.x86_64
wget dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-release-el7-5.noarch.rpm -y
In order to install 5.7, we modify the repo file
yum install mysql-community-server -y
# A temporary password needs to be generated before startup, a certificate is required, and the certificate may expire and an update operation is required
yum update -y
# Start mysql service
service mysqld start
# Set mysql to boot up
chkconfig mysqld on
grep "password"/var/log/mysqld.log
mysql -uroot -p
# enter password
set global validate_password_policy=0;set global validate_password_length=1;
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
grant all privileges on *.* to 'root'@'%' identified by '123456'with grant option;
flush privileges;
vi /etc/my.cnf
# in[mysqld]Partially added:
character-set-server=utf8
# Add at the end of the document[client]Paragraph and in[client]Add paragraph:
default-character-set=utf8
The installation of Mysql 5.7 under CentOS 7 is successful, let's start playing!
Recommended Posts