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

Analysis of the principle and usage of MySQL custom functions

This article uses examples to illustrate the prin...

Introduction to MySQL overall architecture

The overall architecture of MySQL is divided into...

Detailed explanation of DOM style setting in four react components

1. Inline styles To add inline styles to the virt...

The principle and direction of JavaScript this

How to determine what this points to? ①When calle...

Summary of events that browsers can register

Html event list General Events: onClick HTML: Mous...

Using better-scroll component in Vue to realize horizontal scrolling function

About Recently, in the process of learning Vue, I...

Share 13 excellent web wireframe design and production tools

When you start working on a project, it’s importa...

js returns to the previous page and refreshes the code

1. Javascript returns to the previous page history...

Detailed explanation of MySQL database (based on Ubuntu 14.0.4 LTS 64 bit)

1. Composition and related concepts of MySQL data...