Download the mysql source installation package

wget http://dev.mysql.com/get/mysql57-community-release-el7- 8.noarch.rpm
Copy the code

Install the mysql source

yum localinstall mysql57-community-release-el7- 8.noarch.rpm
Copy the code

Check whether the installation is complete

yum repolist enabled | grep "mysql.*-community.*"
Copy the code

Mysql installation

yum install mysql-community-server
Copy the code

Setting Enable Start the mysql service

systemctl enable mysqld
Copy the code

Check the installed mysql version

rpm -aq | grep -i mysql
Copy the code

Start the MySQL service

systemctl restart mysqld
Copy the code

Check the initial password of MySQL

grep 'A temporary password' /var/log/mysqld.log
Copy the code

To obtain the mysql initial database password, perform the following steps:

The initial password is obtained.DhtciCJ? 3rgCopy the code

Based on this password, you can change the password at the first login of root

Change MySQL password

Mysqladmin -u root -p' old password ' 'new password'

Initialize the password change case

mysqladmin  -u root -p 'xxx' password 'xxxxx'
Copy the code
alter user 'root'@'localhost' identified by '.DhtciCJ? 3rg' # random initial password is used here
Copy the code

There may be a change failure problem

Method 1: Make your password complex (this is the most straightforward method)

Disable mysql password strength validation (validate_password)

Edit the configuration file: vim /etc/my.cnf, add the line validate_password=off

Run the systemctl restart mysqld command to restart the mysql service

Set mysql to be accessible remotely (root is not recommended)

1. Log in to the MySQL database: mysql-uroot -p Password

Notice Only the root user can perform this operation

2. Add a user to Aliyun to give access:

See aliyun configuration security group for details

Open user remote access:

www.cnblogs.com/hoge/p/4958…

Mysql > select * from user root;

You should have seen it at the station. The root user can only connect to the mysql server locally.

Add a new user administrtor to the following statement:

Create a new user
CREATE USER 'monitor'@The '%' IDENTIFIED BY 'admin';

-- Assign root to users and support remote access
GRANT ALL PRIVILEGES ON*. *TO 'monitor'@The '%' IDENTIFIED BY 'admin' WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;
Copy the code

Delete this user:

Delete user
DROP USER 'monitor'@The '%';
Drop the specific allocation table
DROP DATABASE IF EXISTS `monitor` ;
Copy the code

3. Select Add security Group rule in security group Settings of Aliyun and enable port 3306. Authorization Object selection0.0.0.0/0All IP addresses are accessible, if you add restrictions you can click on the side of the exclamation mark.

4. Finally: Restart the mysqld service