centos7 install MySQL version 5.7 (full)

centos installation

Version Description: centos7, mysql5.7, not centos7, some commands may not be compatible

  1. Install MySQL server

    # Download and install mysql yum. 
    wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
    yum -y install mysql57-community-release-el7-10.noarch.rpm
    
    # Install MySQL server
    yum -y install mysql-community-server
    
  2. Some configurations of mysql initialization installation

    # Start MySQL server 
    systemctl start mysqld.service
    # Check whether the startup is successful, i.e. whether there is 3306 port.
    netstat -tnlp | grep 3306
    # Query the root password and log in to mysql
    grep "password" /var/log/mysqld.log
    mysql -uroot -p 
    
    # The first operation requires resetting the password, which must be composed of case special characters
    mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
    
    # Authorized remote access% means all hosts can access
    mysql> grant all privileges on *.* to 'root'@'%' identified by 'password' with grant option;
    # Refresh permission information
    mysql> flush privileges; 
    
  3. Modify character set

    vi /etc/my.cnf
    
    [client]
    default-character-set=utf8
    
    [mysqld]
    character-set-server=utf8
    collation-server=utf8_general_ci
    
    # Restart mysql 
    systemctl restart mysqld.service
    
    # Check whether the configuration is successful
    mysql> status; 
    
    Server characterset:    utf8
    Db     characterset:    utf8
    Client characterset:    utf8
    Conn.  characterset:    utf8
    
  4. Configuration can use weak password

    After mysql is upgraded to version 5.7, the password is strengthened.

    • Modify the password field in mysql.user to authentication [string]
    • Add password verification plug-in
    # View current password rules
    mysql> show variables like 'validate_password%';
    +--------------------------------------+--------+
    | Variable_name                        | Value  |
    +--------------------------------------+--------+
    | validate_password_check_user_name    | OFF    |
    | validate_password_dictionary_file    |        |
    | validate_password_length             | 8      | Minimum password length
    | validate_password_mixed_case_count   | 1      | Number of mixed uppercase and lowercase passwords
    | validate_password_number_count       | 1      | Number of password numbers
    | validate_password_policy             | MEDIUM | Password check level
    | validate_password_special_char_count | 1      | Number of password special characters
    +--------------------------------------+--------+
    

    There are two solutions, one is to change the authentication rules, the other is to directly uninstall the password authentication plug-in.

    • Uninstall password authentication plug-in

      mysql> uninstall plugin validate_password;
      
    • Modify validation rules

      mysql> set global validate_password_policy=0;
      mysql> set global validate_password_mixed_case_count=0;
      mysql> set global validate_password_number_count=3;
      mysql> set global validate_password_special_char_count=0;
      mysql> set global validate_password_length=3;
      

Modify mysql password

If you have logged in to mysql, you can change the password directly

# Method 1. Set the password of the current login user
mysql> set password=password('newpassword');
# Method 2. Directly change the user table
mysql> use mysql;
mysql> update user set authentication_string=password('123abc') where user='root';
# Method 3. Change password
mysql> alter user root@'localhost' identified by '123456';

If you do not log in to mysql, you can skip the permission check to change the password.

vi /etc/my.cnf
[mysqld]
skip-grant-tables

# Then restart mysql. You don't need the root password to log in to MySQL. Then you can play whatever you like. 

windows installation

Generally speaking, the next step is over, but I may have downloaded a test version at that time. There is a 1045 error. It is estimated that the current version is not available. The solution is to skip the permission check and reset the password. Here is an operation method for novices.

1. Stop mysql service first, and then cmd to mysql bin directory
2. mysqld -nt --skip-grant-tables
 3. Start mysql to execute mysqladmin - U root flush privileges password < password >

A little promotion

It's not easy to create. I hope to support my open source software and my gadgets. Welcome to gitee to click stars, fork, and mention bug s.

Excel general import and export, support excel formula Blog address: https://blog.csdn.net/sanri1993/article/details/100601578 gitee: https://gitee.com/sanri/sanri-excel-poi

Use template code, generate code from database, and some small tools often used in projects Blog address: https://blog.csdn.net/sanri1993/article/details/98664034 gitee: https://gitee.com/sanri/sanri-tools-maven

Keywords: Programming MySQL yum Excel RPM

Added by DusterG20 on Sat, 19 Oct 2019 10:52:32 +0300