This blog is mainly extracted from the Internet, make a record, if there is the same demand in the future, you can directly turn over your own records. Thank you to the two great gods:
https://www.cnblogs.com/luohanguo/p/9045391.html
https://www.cnblogs.com/debmzhang/p/5013540.html
Installation steps
1. Download the rpm package of MySQL 5.7 from the official website
http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
2. If windows system is used locally, XFtp is used to upload to linux server;
If it's a mac system, use the following command to replace the red part with the server ip
scp mysql57-community-release-el7-10.noarch.rpm root@192.168.1.106:/opt
3. Install Yum Repository
yum -y install ysql57-community-release-el7-10.noarch.rpm
4. Installing MySQL server takes some time.
yum -y install mysql-community-server
5. Replace the default configuration file / etc/my.cnf, mainly to change the character set to utf8
[mysqld]
#Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
character-set-server=utf8
lower_case_table_names=1
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
6. Start the mysql service and set it to boot
systemctl start mysqld.service
systemctl enable mysqld.service
7. Query the default password
cat /var/log/mysql.log | grep password
8. Log in to mysql with the default password
mysql -u root -p
9. However, no operation can be performed at this time. The password must be changed first.
The password has some format restrictions. If you want to remove the restrictions, you must first modify the system variable values.
>mysql set global validate_password_policy=0;
>mysql set global validate_password_length=1;
>mysql SET PASSWORD = PASSWORD('your new password');
>mysql ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
>mysql flush privileges;
10. Exit myql and log in with the updated password
Installation location
First query the name of the package, then find the location.
rpm -qa | grep mysql
rpm -ql Package name
It should be noted that databases are generally stored in the / var/lib/mysql directory