centOS8 install MySQL8 (pro test)

If you are still looking for a tutorial on installing MySQL on CentOS and can't find it, then you don't need to turn around if you see it here.
To be honest, I have been doing it for a day today.

Download MySQL

MySQL8.0.21 version download link: click here

Insert picture description here

Pull this drop-down box, Fedora, Unbuntu, etc. Anyway, you can't find centOS, right? Then there are a bunch of people on the Internet saying that centOS supports mariaDB by default. Anyway, my CentOS does not.

Do this:
Insert picture description here

It can be downloaded directly under Linux system.

Insert picture description here


Start configuration

First, check if there is MariaDB in your system:

rpm -qa | grep mariadb

If there is, it will give you a version of the response, if not, there will be no

If you are lucky, and you really have it, then uninstall it: rpm -e version number --nodeps


Create a directory, called mysql, where you can remember it.
Then drag the downloaded installation package of MySQL to your mysql directory, you can drag it in with the code, or you can drag it in the file manager.

Decompression: tar -xvf mysql-8.0.21-1.el7.x86_64.rpm-bundle.tar
other people's pictures, the meaning is the same
Insert picture description here


Install common through the rpm -ivh mysql-community-common-8.0.21-1.el7.x86_64.rpm --nodeps --force command

Insert picture description here

Install libs by rpm -ivh mysql-community-libs-8.0.11-1.el7.x86_64.rpm --nodeps --force command

Insert picture description here

Install the client through the rpm -ivh mysql-community-client-8.0.11-1.el7.x86_64.rpm --nodeps --force command

Insert picture description here

Install the server through the rpm -ivh mysql-community-server-8.0.11-1.el7.x86_64.rpm --nodeps --force command

Insert picture description here

View the mysql installation package through the rpm -qa | grep mysql command

Insert picture description here


Through the following commands, complete the initialization and related configuration of the mysql database

mysqld --initialize;
chown mysql:mysql /var/lib/mysql -R;
systemctl start mysqld.service;
systemctl enable mysqld;

Insert picture description here


View the database password through the cat /var/log/mysqld.log | grep password command

Insert picture description here


Enter the database login interface through mysql -uroot -p and press Enter

Enter the password you just found to log in to the database, just copy and paste. The MySQL login password is not displayed either

Insert picture description here

Change the password through the ALTER USER'root'@'localhost' IDENTIFIED WITH mysql_native_password BY'root'; command,
this time the password is changed to root

Exit MySQL with the exit; command, and then log in again with the new password


Through the following command, remote access authorization

Insert picture description here


Add remote login user

By default, only the root account is allowed to log in locally. If you want to connect to mysql on other machines, you must modify root to allow remote connections, or add an account that allows remote connections.

Modify the remote access permissions of the root user:

Select the mysql database: use mysql;

View the relevant information of the current root user in the user table of the mysql database:

select host, user from user;

Check the host of the root user in the table. The localhost should be displayed by default. It only supports local access and does not allow remote access.

Authorize all permissions of the root user and set up remote access

GRANT ALL ON *.* TO 'root'@'%';

如果报错:ERROR 1410 (42000): You are not allowed to create a user with GRANT

update user set host='%' where user ='root';

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

flush privileges;

If necessary, execute the command that was previously authorized to report an error to be successful, and finally use flush privileges; command to refresh.


Sqlyog link 2058 exception

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

The password is the password you modified. Then reconnect in SQLyog, the connection can be successful, OK.

If an error is reported: ERROR 1396 (HY000): Operation ALTER USER failed for'root'@'localhost' then use the following command:

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'password';

Guess you like

Origin blog.csdn.net/qq_43762191/article/details/108896515