Install MySQL5 database in Centos7 environment under ESC cloud server

  1. Run the following command to update the YUM source.

    rpm -Uvh  http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
    
  2. Run the following command to install MySQL.

    NOTE If the kernel version of the operating system you are using is el8, an error message No match for argument may be displayed. You need to run the command yum module disable mysql to disable the default MySQL module before installing MySQL.

    yum -y install mysql-community-server --nogpgcheck
    
  3. Run the following command to check the MySQL version number.

    mysql -V
    

    The returned results are as follows, indicating that MySQL is installed successfully.

    mysql  Ver 14.14 Distrib 5.7.31, for Linux (x86_64) using  EditLine wrapper
    
  4. Run the following command to start MySQL.

    systemctl start mysqld
    
  5. Run the following commands in sequence to set up MySQL to start on startup.

    systemctl enable mysqld
    systemctl daemon-reload
    
  6. Run the following command to view the initial MySQL password.

    grep "password" /var/log/mysqld.log
    

    An example of the returned result is as follows. In this example, the initial password is +47,uijcojcU.

    2020-08-28T03:01:49.848762Z 1 [Note] A temporary password is generated for root@localhost: +47,uijcojcU
    
  7. Run the following command to configure MySQL security.

    mysql_secure_installation
    

    Security configuration includes the following five aspects:

    1. Reset the password of the root account.

      Note Please keep the password information of the root account safe.

      Enter password for user root: #Enter the root user's initial password obtained in the previous step. The existing password for the user account root has expired. Please set a new password. New password: #Enter the new password, with a length of 8 to 30 characters and must contain both uppercase and lowercase English letters, numbers and special symbols. Special symbols can be ()` ~!@#$%^&*-+=|{}[]:;'<>,.?/Re-enter new password: #Repeatedly enter the new password. The 'validate_password' plugin is installed on the server. The subsequent steps will run with the existing configuration of the plugin. Using existing password for root. Estimated strength of the password: 100 Change the password for root ? ((Press y|Y for Yes, any other key for No) :Y #Press Y, and re-enter the password set in the previous step. New password: #Enter the new password again. Re-enter new password: #Repeat the new password. Estimated strength of the password: 100Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) :Y #Press Y to use the new password.
      
    2. Enter Y to delete the anonymous user account.

      By default, a MySQL installation has an anonymous user,
      allowing anyone to log into MySQL without having to have
      a user account created for them. This is intended only fortesting, and to make the installation go a bit smoother.
      You should remove them before moving into a production
      environment.
      
      Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y  #是否删除匿名用户,输入Y
      Success.
      
    3. Enter Y to disable remote login by the root account.

      Normally, root should only be allowed to connect from'localhost'. This ensures that someone cannot guess atthe root password from the network.
      
      Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y #禁止root远程登录,输入Y
      Success.
      
    4. Enter Y to delete the test library and access permissions to the test library.

      By default, MySQL comes with a database named 'test' that
      anyone can access. This is also intended only for testing,and should be removed before moving into a production
      environment.
      
      Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y #是否删除test库和对它的访问权限,输入Y
       - Dropping test database...
      Success.
      
       - Removing privileges on test database...
      Success.
      
    5. Enter Y to reload the authorization tables.

      Reloading the privilege tables will ensure that all changesmade so far will take effect immediately.Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y #Whether to reload the authorization table, enter YSuccess.All done!
      

        After installation: use navicat to log in, if the access fails, the following error will be reported: 1130,"Host 'xx' is not allowed to connect to this MySQL server" 

Use: mysql -uroot -p to log in, enter the following command line after entering the database,

 

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'your login password' WITH GRANT OPTION;

Then refresh to access

If there is no response, you can use the flush privileges command to refresh

Refresh authority refers to the command used to refresh authority in MySQL, mainly used to reload user authority. The command format is as follows:

FLUSH PRIVILEGES;


 

Guess you like

Origin blog.csdn.net/liqz666/article/details/130057829