Home  >  Article  >  Database  >  Cloud server Centos7 builds MySQL database (learning record)

Cloud server Centos7 builds MySQL database (learning record)

藏色散人
藏色散人forward
2020-04-02 08:59:172072browse

Nonsense at the beginning:

Before my student ID card expired, I quickly bought Tencent Cloud for three years. Why should I use Tencent’s products? Isn’t it because other people’s mini programs support it? Without further ado, let’s get to the point.

1. Download the yum source of MySQL

Centos7 does not have the yum source of MySQL. We download different versions of the source to install different versions of MySQL. You can choose to download it yourself. , or you can download it according to the command selected below.

wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm

2. Install the downloaded rpm file

rpm -ivh mysql57-community-release-el7-8.noarch.rpm

3. Install Mysql with yum

yum install mysql-server

4 , try to log in to MySQL

mysql -uroot -proot

This place may report an error:

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

This is a /var/lib/mysql permissions problem, modify the MySQL permissions to the current user

sudo chown -R xxx:xxx /var/lib/mysql

xxx is the current user name and group

Restart the MySQL service

service mysqld restart

5. Failed to log in to obtain the initial password

cat /var/log/mysqld.log | grep password

Among them A temporary password is generated for root@localhost: * localhost: What follows is the initial password.

mysql -uroot -p

Enter the password to log in

6. After successful login, change the initial password first

set global validate_password_policy=0;
set global validate_password_length=4;
alter user 'root'@'localhost' identified by 'root’;

7. In this way, the MySQL installation is complete!

Recommended: "mysql video tutorial"

The above is the detailed content of Cloud server Centos7 builds MySQL database (learning record). For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete