Install MySQL 8.0.24 on Kirin system

Let me introduce the detailed steps to install MySQL 8.0.24 on the Kylin system, provided that you have downloaded mysql-8.0.24-linux-glibc2.12-x86_64.tar.xzthe installation package. In fact, the installation is very simple, but there are pitfalls, and the problem is very serious! Since there are few articles and blogs related to the Kirin system, we have encountered a very big pitfall, so I would like to share it with you! The download address for the installation package is as follows:
MySQL Community Downloads
Insert image description here

Tips for avoiding pitfalls:
Kirin has not activated the system. When entering commands, it often prompts that the permissions are insufficient. It is impossible to install software through the administrator or run scripts with execution permissions. Even if sudo is used to execute commands, an error is reported without permissions, and there is no possibility of successful installation! ! !

Open the terminal and execute the command: sudo setstatus softmode -p
(This is caused by security being turned on by default, and you can use commands to remove security restrictions)

  1. Unzip the installation package:

    Open a terminal window and use the following command to decompress the installation package:

    tar -xvf mysql-8.0.24-linux-glibc2.12-x86_64.tar.xz
    
  2. Move files:

    Move the unzipped MySQL files to the appropriate directory, for example /usr/local/mysql:

    sudo mv mysql-8.0.24-linux-glibc2.12-x86_64 /usr/local/mysql
    
  3. Create MySQL users and groups:

    Before continuing with the installation, create a user and group for running MySQL. The following commands can be used:

    sudo groupadd mysql
    sudo useradd -r -g mysql -s /bin/false mysql
    
  4. Configure MySQL:

    Enter the MySQL directory, create the necessary configuration files and initialize the database:

    cd /usr/local/mysql
    sudo mkdir mysql-files
    sudo chown mysql:mysql mysql-files
    sudo chmod 750 mysql-files
    sudo bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
    
  5. Start the MySQL service:

    Start the MySQL server:

    sudo bin/mysqld_safe --user=mysql &
    
  6. Set MySQL root password:

    After first startup, MySQL generates a temporary password. Use the following command to change the root password:

    sudo bin/mysql_secure_installation
    
  7. Add MySQL to the system path:

    Edit ~/.bashrcthe file and add the following lines to the end of the file:

    export PATH=$PATH:/usr/local/mysql/bin
    

    Then execute the following command to make the changes take effect:

    source ~/.bashrc
    

To run MySQL on the Kylin system and connect remotely, you also need to complete the following steps:

  1. Configure remote access : By default, MySQL does not allow remote access. To enable remote access
    For security reasons, it is not recommended to directly use the root user for remote connections. You can create a dedicated user and grant it the appropriate permissions. At the MySQL prompt, run the following command:

    CREATE USER 'your_username'@'%' IDENTIFIED BY 'your_password';
    GRANT ALL PRIVILEGES ON *.* TO 'your_username'@'%' WITH GRANT OPTION;
    FLUSH PRIVILEGES;
    

    Please 'your_username'replace with your username and 'your_password'with your password.

  2. Restart the MySQL service : After making any changes, restart the MySQL service for the changes to take effect:

    sudo service mysql restart
    

You can now use the remote MySQL client to connect to the MySQL server running on your Kylin system. In the remote MySQL client, set the server address to the IP address of your Kylin system, and the username and password are the user credentials you created in step 6.

Please note that enabling remote access will increase security risks. It is recommended to take some security measures, such as using complex passwords and granting only required permissions.

Guess you like

Origin blog.csdn.net/weixin_53742691/article/details/132481023