Home  >  Article  >  Database  >  How to install mysql in rpm in centos

How to install mysql in rpm in centos

WBOY
WBOYOriginal
2022-01-20 13:59:324813browse

Method: 1. Use the "yum -y install mysql57-community-release-el7-10.noarch.rpm" command to download the rpm file; 2. Use the "yum install -y mysql-server mys" command to install it That’s it.

How to install mysql in rpm in centos

The operating environment of this tutorial: linux7.3 system, mysql8.0.22 version, Dell G3 computer.

How to install mysql in rpm in centos

1. Check whether MySQL is installed on the server

    rpm -qa|grep -i mysql

1.1 If so, delete it or not Continue to the next step

    yum remove mysql mysql-server mysql-libs compat-mysql51
    rm -rf /var/lib/mysql
    rm /etc/my.cnf

After the deletion is completed, recheck if there is any, continue to delete yum remove existing name

2. Download the MySQL RPM file

   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

2.1 Install MySQL (always Y is fine)

    yum install -y mysql-server mysql mysql-deve

2.2 After the installation is completed, check whether the installation is successful

    rpm -qi mysql-community-server

3 Start the mysql service

    systemctl start  mysqld.service

3.1 Check the startup status

    systemctl status mysqld.service

How to install mysql in rpm in centos

3.2 Check the original password

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

How to install mysql in rpm in centos

Log in to MySQL based on your original password

    mysql -u root -p

4. Modify the MySQL default password

    ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';

new password is the new password set for you. Note: The password setting must contain uppercase and lowercase letters, numbers and special symbols (,/';:, etc.), otherwise the configuration cannot be successful

5. Configure remote service

Execute the following command to enable remote access restrictions (note: the IP enabled by the following command is 192.168.0.1. If you want to enable all, use % instead of IP)

        grant all privileges on *.* to 'root'@'%' identified by 'password' with grant option;

password is the password you set yourself. Then enter the following two lines of commands

        flush privileges;
        exit

How to install mysql in rpm in centos

6. Modify the MySQL language

First log in to mysql again, and then enter status:

How to install mysql in rpm in centos

You can see that the green arrow is not utf-8

So we exit mysql first, and then modify the file content in the my.cnf file in the etc directory

After entering the file, add four lines of code

How to install mysql in rpm in centos

The code is

    [client]
    default-character-set=utf8
    character-set-server=utf8
    collation-server=utf8_general_ci

After saving the changed my.cnf file, restart mysql, Then enter status to check again, and you will find the changes

How to install mysql in rpm in centos

If an error is reported after MySQL login after restarting, please use the above 3.1 to check whether the startup status of MySQL is

How to install mysql in rpm in centos

If not, please use the above 3 to start MySQL, check the startup status and then log in to MySQL to check the character format

Recommended learning: mysql video tutorial

The above is the detailed content of How to install mysql in rpm in centos. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn