Article Directory
-
-
-
- Create a directory and enter (first step)
- Obtain the MySQL installation package (Step 2)
- Unzip the installation package (Step 3)
- Query related installation packages of mariadb (Step 4)
- Uninstall the necessary operations under the mariadb database centos7.6 (step 5)
- Start the real installation of MySQL (Step 6)
- Start MySQL (Step 7)
- Set the root user password (Step 8)
- Exit the MySQL database
-
-
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
-
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
-
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
-
Set the root password, set password for'root'@'localhost'=password('12345678')
-
Run flush privileges to make the password setting take effect
Exit the MySQL database
quit