CentOS7 install MySQL5.7 using yum

  1. Download and install the official Yum Repository for MySQL

    wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
    yum localinstall mysql57-community-release-el7-8.noarch.rpm -y
    yum install mysql-community-server mysql -y
    Copy the code
  2. Initialize and configure MySql

    1. Start: systemctl start mysqld

    2. Check the status: systemctl status mysqld

    3. To view the initial password:grep "password" /var/log/mysqld.log

    4. Mysql -uroot -p mysql -uroot -p

    5. After these two Settings, the password is very simple and will not report errors

      set global validate_password_policy=0;        
      set global validate_password_length=1;
      Copy the code
    6. ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘123456’;

    7. Grant all PRIVILEGES on *.* to ‘root’@’%’ identified by ‘123456’ with grant option;

    8. Refresh privileges: Flush PRIVILEGES;

    9. Change the default character set to vi /etc/my.cnf

      [mysqld]
      default-storage-engine=INNODB
      character-set-server = utf8mb4
      collation-server = utf8mb4_general_ci
      
      [client]
      default-character-set=utf8mb4
      [mysql]
      default-character-set=utf8mb4
      Copy the code
    10. Run the systemctl restart mysqld command to restart mysql

    11. Start system: systemctl enable mysqld

    12. Mysql57-community-release-el7-8.noarch: yum -y remove mysql57-community-release-el7-8.noarch: yum -y remove mysql57-community-release-el7-8.noarch