Linux (CentOS7) uses RPM to install mysql 8.0.11

1, Installation preparation

1. View Linux related information (Linux command line operation)

(1) Check the Linux version to download the corresponding mysql.

[See Linux Message:
    uname -a



(2) check whether mysql has been installed.

[check whether mysql is installed]
    rpm -qa | grep -i mysql, if installed, will output the relevant package name
[delete related files if mysql has been installed]
    RPM - E [-- nodes] package name (here the package name is the name found by the above command)




2. Download mysql

(1) Official website address

[Official website address:]


(2) Choose the right version

[Choose the right one rpm Bao]



2, Start installation

1. Transfer files to / opt directory

Use xFtp6 to transfer the downloaded files from windows system to Linux system (optional operation, you can download directly on Linux).



2. RPM installs mysql

(1) Step 1: execute the installation command

rpm -ivh package name

[installation sequence: (packages depend on each other, so you must pay attention to the installation sequence]
    Install common first
    Reinstall libs (make sure that mariadb is uninstalled, and centos7 supports mariadb by default, mysql is not supported, and there will be conflicts if it is not uninstalled)
    Reload client
    Last install server

    [root@localhost opt]# rpm -ivh mysql-community-common-8.0.11-1.el7.x86_64.rpm
   [root@localhost opt]# rpm -e --nodeps mariadb-libs-5.5.64-1.el7.x86_64
   [root@localhost opt]# rpm -ivh mysql-community-libs-8.0.11-1.el7.x86_64.rpm
   [root@localhost opt]# rpm -ivh mysql-community-client-8.0.11-1.el7.x86_64.rpm 
   [root@localhost opt]# rpm -ivh mysql-community-server-8.0.11-1.el7.x86_64.rpm





(2) Step 2: check whether the installation is successful

[Mode 1:]
    mysql After the installation is successful, it will be automatically established mysql User, user group.
    cat /etc/passwd | grep mysql
    cat /etc/group | grep mysql
[Mode 2:]
    mysqladmin --version



3. Start mysql service

(1) Step 1: check whether the current service is started

[Mode 1:]
    ps -ef | grep mysql
[Mode 2:]
    service mysqld stauts



(2) Step 2: start and stop mysql service

[start-up mysql Service:
    service mysql start

[Close mysql Services:(Optional operation)]
    service mysql stop



4. Connect mysql

An error is reported when connecting to the database for the first time.

[First landing:]

[If an error message is prompted: (indicates that a password is required)
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

(1) Solution 1: check the initial password and log in with it.

[Solution 1: (check the initial password for login)
    cat /var/log/mysqld.log | grep password



(2) Solution 2:

[solution 2: (edit my.cnf file to skip password]
    Find the mysql configuration file (ending with. cnf).
        find / -name "*/.cnf"
       mysql --help |grep -A 1 'Default options'

    Edit the configuration file (my.cnf), locate [mysqld], and add 
        Skip grant tables is used to skip password login
   Restart service:
        service mysqld restart
    Login without password:





5. Change initial password

Through the above two methods, you can enter mysql, but the password is the initial password, or there is no password, which is certainly difficult to operate. A custom password is required.
(1) Set the login password and connect to the database again.

[Set password:]
    mysql> ALTER USER root@localhost IDENTIFIED  BY '123456';

[If an error occurs:]
    ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

[Solution: (execute the following statement)
    mysql> flush privileges;
    mysql> ALTER USER root@localhost IDENTIFIED  BY '123456';
[Login again]
    mysql -uroot -p 



(2) After setting the initial password, you need to edit / etc/my.cnf to remove the skip grant tables you added earlier.
Restart the service.

[root@localhost /]# vim /etc/my.cnf
[root@localhost /]# service mysqld restart

Tags: Linux MySQL RPM MariaDB

Posted on Thu, 26 Mar 2020 08:57:43 -0400 by planetsim