Tutorial on installing MYSQL8.X on Centos

Tutorial on installing MYSQL8.X on Centos

MySQL installation (4, 5, 6 can be omitted)

Statement: CentOS version is 7.6, and the installed MySQL version is 8.0.17

1. First, uninstall the MySQL-related software that comes with the machine, including MariaDB.

rpm -pa | grep mysql #Delete the searched results using `rm -rf filename`, skip if none exists rpm -pa | grep mariadb #Delete the searched results using `rm -rf filename`, skip if none exists find / -name mysql #Find and delete related folders, skip if none exists (same as above)
find / -name mariadb #Find and delete related folders, skip if there is none (same as above)

2. Back up the default repo source of centOS, download the repo source of Alibaba Cloud or NetEase to replace the default source.

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

cd /etc/yum.repos.d/
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

3. Clean up yum and create yum cache.

sudo yum clean all
sudo yum makecache

4. View mysql related content in the software source warehouse

yum repolist | grep mysql

5. Check whether the corresponding version of MySQL is enabled

cat /etc/yum.repos.d/mysql-community

6. Set the version to be installed to enabled (I installed MySQL Community Edition 8.0 here)

yum-config-manager --enable mysql80-comminity

7. Perform the installation

yum install mysql-community-server.x86_64

8. Check the running status of MySQL. It is not started by default after installation.

# Check the running status of the MySQL service. Active means it has been started, inactive means it has not been started, and failed means it has failed to start. systemctl status mysqld.service
# Start the MySQL service systemctl start mysqld.service
# Stop the MySQL service systemctl stop mysqld.service
# Restart the MySQL service systemctl restart mysqld.service

9. Check the initial password

The newly installed version of MySQL will automatically generate a temporary password and save it in `/etc/log/mysqld.log`

cat /var/log/mysqld.log | grep "password"

10. Log in using the initial password

Copy the password from the previous step and enter `mysql -uroot -p password`, or press Enter without entering a password first, and paste the password where it is prompted (the password is not displayed, just paste it once).

11. Change the initial password

show databases;
use mysql;
# For example, if you want to change the password to NewPassword!, for security reasons, try to include uppercase and lowercase letters, numbers, and symbols. alter 'user'@'localhost' identified by 'NewPassword!';

12. Modify access permissions to enable remote connection

update user set Host='%' where User='root' and Host='localhost';

13. Refresh permissions

flush privileges;

14. Create a new user

create user usernameidentified by 'password'; 
# For example, when creating a user, specify the host that can be accessed, as well as the database tables that can be accessed and the corresponding permissions create user username@'hostname' identified by 'password';
grant select, update, create, delete on database name.table name to user name;

15. Grant permissions, remember to refresh the permissions to take effect

grant select on database name.table name to user; # all permissions can be used

flush privileges;

MySQL backup

Backup: data table structure + data

mysqdump -u root db1 > db1.sql -p;

Backup: Data table structure

mysqdump -u root -d db1 > db1.sql -p;

Import existing data into a database

First create a new database

create database db10;

Import the existing database file into the db10 database

mysqdump -u root -d db10 < db1.sql -p;

==Note==

==If the database reports an error:==

==“Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.”==

Solution:

Database initialization:

rm -rf /var/log/mysql.log
rm -rf /var/ib/mysql

Summarize

The above is the tutorial on how to install MYSQL8.X on Centos that I introduced to you. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • Detailed tutorial on how to compile and install mysql8.0.29 in CentOS8 deployment LNMP environment
  • Tutorial on installing MySQL 8.0.11 using RPM on Linux (CentOS7)
  • CentOS7.5 installation of MySQL8.0.19 tutorial detailed instructions
  • Install CentOS7 in VMware (set static IP address) and install mySql database through docker container (super detailed tutorial)
  • Tutorial diagram of installing mysql8.0.18 under linux (Centos7)
  • Tutorial on installing MySQL 5.7.28 on CentOS 6.2 (mysql notes)
  • Tutorial analysis of quick installation of mysql5.7 based on centos7

<<:  How to simply encapsulate axios in vue

>>:  A Deep Dive into the MySQL InnoDB Storage Engine

Recommend

DOM operation table example (DOM creates table)

1. Create a table using HTML tags: Copy code The ...

How to install phabricator using Docker

I am using the Ubuntu 16.04 system here. Installa...

How to implement Mysql scheduled task backup data under Linux

Preface Backup is the basis of disaster recovery....

Reasons and solutions for slow MySQL query stuck in sending data

Because I wrote a Python program and intensively ...

Solution to the problem of passing values ​​between html pages

The first time I used the essay, I felt quite awkw...

Causes and solutions for cross-domain issues in Ajax requests

Table of contents 1. How is cross-domain formed? ...

Instructions for using JSON operation functions in Mysql5.7

Preface JSON is a lightweight data exchange forma...

VMware vsphere 6.5 installation tutorial (picture and text)

vmware vsphere 6.5 is the classic version of vsph...

Linux method example to view all information of the process

There is a task process on the server. When we us...

Common usage of regular expressions in Mysql

Common usage of Regexp in Mysql Fuzzy matching, c...

Encoding problems and solutions when mysql associates two tables

When Mysql associates two tables, an error messag...

Unbind SSH key pairs from one or more Linux instances

DetachKeyPair Unbind SSH key pairs from one or mo...