If you are still looking for a tutorial to install MySQL on CentOS and can’t find it, then you don’t need to turn it around if you see it here.
To be honest, I have been doing it for a day today.
Download link of MySQL8.0.21 versions: click here
Pull this drop-down box, Fedora, Unbuntu have everything, 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 have it.
Do this:
It can be downloaded directly under Linux system.
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.
Unzip: tar -xvf mysql-8.0.21-1.el7.x86_64.rpm-bundle.tar
Other people’s pictures mean the same
Install common through the rpm -ivh mysql-community-common-8.0.21-1.el7.x86_64.rpm --nodeps --force command
Install libs through the rpm -ivh mysql-community-libs-8.0.11-1.el7.x86_64.rpm --nodeps --force command
Install the client through the rpm -ivh mysql-community-client-8.0.11-1.el7.x86_64.rpm --nodeps --force command
Install the server through the rpm -ivh mysql-community-server-8.0.11-1.el7.x86_64.rpm --nodeps --force command
View the mysql installation package through the rpm -qa | grep mysql command
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;
View the password of the database through the cat /var/log/mysqld.log | grep password command
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.
Modify the password through the ALTER USER'root'@'localhost' IDENTIFIED WITH mysql_native_password BY'root'; command
Now 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
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'@'%';
If an error is reported: 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';
Recommended Posts