Use source to install MySQL under CentOS7
Reference article: https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/
For some reason, MySQL is removed from the default yum source of CentOS7 and replaced by MariaDB.
Yum list mysqlError: No matching Packages to listyum list mariadbAvailable Packagesmariadb.x86_64 *: *. *.
If you still want to install mysql through yum at this time, you have to make some preparations.
First of all to
Https://dev.mysql.com/downloads/repo/yum/
This site downloads the corresponding rpm source
Download the corresponding Linux 7 version
Wget-c https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
Import the downloaded file into the source
Rpm-Uvh mysql57-community-release-el7-11.noarch.rpm
At this point, you can install mysql on yum.
Yum-y install mysql-community-server
Start and initialize mysql
Systemctl start mysqld
At this point, you can log in to mysql with root users.
What? You said you didn't know the password. All right, check the mysql log.
Grep 'temporary password' / var/log/mysqld.log
All right, we're finally in the mysql, so let's do something, hint.
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
Let's change the default password
ALTER USER 'root'@'localhost' IDENTIFIED BY' 123456 investors error 1819 (HY000): Your password does not satisfy the current policy requirements
Say my password is not secure! My own local database for testing. Do I bother if you ask me to set up a complicated password?
Find / etc/my.cnf
Here is a brief introduction to the configuration file of this mysql
[mysqld] # Server default character set character-set-server=utf8# table name defaults to lowercase lower_case_table_names=1# listening port default 3306port=3306# SQL execution mode whether sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES# verifies password validate-password=OFF
Configure to restart the mysql service after turning off password verification
Systemctl restart mysqld
At this time, log in to mysql to change the default password and you can use a simple password.
If you want to log in remotely using root users, you also need to change the Host of root users
Use mysql;update user set host='%' where user='root';flush privileges
At this time, the construction will be completed.