Linux (basic)-install MySQL5.7

Create a directory and enter (first step)

mkdir /opt/mysql

cd /opt/mysql

Obtain the MySQL installation package (Step 2)

wget http://dev.mysql.com/get/mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar

Unzip the installation package (Step 3)

tar -xvf mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar

Query related installation packages of mariadb (Step 4)

rpm -qa | grep mari

Uninstall the necessary operations under the mariadb database centos7.6 (step 5)

Because the mariadb database conflicts with the MySQL database

Start the real installation of MySQL (Step 6)

rpm -ivh mysql-community-common-5.7.26-1.el7.x86_64.rpm

rpm -ivh mysql-community-libs-5.7.26-1.el7.x86_64.rpm

rpm -ivh mysql-community-client-5.7.26-1.el7.x86_64.rpm

rpm -ivh mysql-community-server-5.7.26-1.el7.x86_64.rpm

If the following error occurs:

libncurses.so.5()(64bit) is mysql-community-client-5.7.26-1.el7.x86_64 requires
libtinfo.so.5()(64bit) is mysql-community-client-5.7.26-1. el7.x86_64 required

Solution:

yum install libncurses*

Start MySQL (Step 7)

systemctl start mysqld.service

Set the root user password (Step 8)

MySQL automatically sets a random password for the root user, run grep "password" /var/log/mysqld.log to see the current password

  1. Run mysql -u root -p, log in as the root user, prompt for a password, just use the random password mentioned above, you can successfully log in to the MySQL command line

  2. Set root password policy. For personal development environment, if you want to set a relatively simple password (set a complex password in a production environment), you can run set global validate_password_policy=0 (validate_password_policy default value is 1)

    Policy Tests Performed
    0 or LOW Length (default is 8 bits)
    1 or MEDIUM Length; numeric, lowercase/uppercase, and special characters
    2 or STRONG Length; numeric, lowercase/uppercase, and special characters; dictionary file

    After entering the MySQL command and pressing Enter to execute it, if you want to exit, you can enter an English semicolon, and then press Enter to exit

  3. Set the root password, set password for'root'@'localhost'=password('12345678')

  4. Run flush privileges to make the password setting take effect

Exit the MySQL database

quit

Guess you like

Origin blog.csdn.net/wxy_csdn_world/article/details/115266916