MySQL installation-Linux version

MySQL-Linux version installation

1. Prepare a Linux server

Cloud server or virtual machine can be;

The version of Linux is CentOS7;

2. Download the MySQL installation package for Linux

download link

insert image description here

3. Upload the MySQL installation package

Use FinalShell software to upload!

4. Create a directory and unzip it

mkdir mysql

tar -xvf mysql-8.0.26-1.el7.x86_64.rpm-bundle.tar -C mysql

5. Install the mysql installation package

cd mysql

rpm -ivh mysql-community-common-8.0.26-1.el7.x86_64.rpm 

rpm -ivh mysql-community-client-plugins-8.0.26-1.el7.x86_64.rpm 

rpm -ivh mysql-community-libs-8.0.26-1.el7.x86_64.rpm 

rpm -ivh mysql-community-libs-compat-8.0.26-1.el7.x86_64.rpm

yum install openssl-devel

rpm -ivh  mysql-community-devel-8.0.26-1.el7.x86_64.rpm

rpm -ivh mysql-community-client-8.0.26-1.el7.x86_64.rpm

rpm -ivh mysql-community-icu-data-files-8.0.28-1.el7.x86_64.rpm

rpm -ivh  mysql-community-server-8.0.26-1.el7.x86_64.rpm

Possible problems: mariadb-libs is replaced by mysql-community-libs-8.0.25-1.el7.x8664

One command: yum remove mysql-libssolve, just clear the previously installed dependencies

6. Start the MySQL service

systemctl start mysqld
systemctl restart mysqld
systemctl stop mysqld

7. Query the automatically generated root user password

grep 'temporary password' /var/log/mysqld.log

Command line execution instructions:

mysql -u root -p

Then enter the automatically generated password from the above query to complete the login

8. Modify root user password

After logging in to MySQL, you need to change the automatically generated password that is inconvenient to remember, and change it to a password that you are familiar with and easy to remember

ALTER USER USER() IDENTIFIED BY 'Admin2022!';

# 查看 mysql 初始的密码策略
SHOW VARIABLES LIKE 'validate_password%';
# 设置密码的验证强度等级
set global validate_password.policy = LOW;
# 设置密码规定的长度
set global validate_password.length = 4;
# 关闭检查用户名(此方式可设置用户名和密码一致)
set global validate_password.check_user_name = off;

ALTER  USER  'root'@'localhost'  IDENTIFIED BY 'root';

9. Create a user

The default root user can only access the current node localhost, and cannot access remotely. We also need to create a root account for remote access by users

create user 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'admin';

10. And assign permissions to the root user

grant all on *.* to 'root'@'%';

11. Reconnect to MySQL

mysql -u root -p

then enter the password

Note: If you can’t connect, please make sure that the Linux firewall is closed, or open the specified port

12. Connect to MySQL remotely through Navicat

13. Set the mysql service to start automatically at boot

Check whether the MySQL service starts automatically

 systemctl list-unit-files | grep mysqld.service

enabled by default;

If it is not enabled, you can run the following command to set auto-start

systemctl enable mysqld.service			# 打开开机自启动
systemctl disable mysqld.service		# 关闭开机自启动

Guess you like

Origin blog.csdn.net/zhang_0202/article/details/131035632