Centos install MYSQL8.X tutorial

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

Disclaimer: CentOS version is 7.6, installed MySQL version is 8.0.17

  1. First, uninstall the mysql related to this machine, including MariaDB.
rpm -pa | grep mysql #Use the search results`rm -rf file name`Delete, skip if not
rpm -pa | grep mariadb #Use the search results`rm -rf file name`Delete, skip if not
find /-name mysql #Find and delete related folders, skip if not (same as above)
find /-name mariadb #Find and delete related folders, skip if not (same as above)
  1. 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
  1. Clean up yum and create yum cache.
sudo yum clean all
sudo yum makecache
  1. View mysql related content in the software source warehouse

yum repolist | grep mysql

  1. Check whether the corresponding version of mysql is enabled

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

  1. Set the version that needs to be installed to the enabled state (I installed the mysql community version 8.0 version here)

yum-config-manager --enable mysql80-comminity

  1. Perform installation

yum install mysql-community-server.x86_64

  1. Check the running status of mysql, the default is not started when just installed
# Check the running status of the MySQL service. Active means started, inactive means not started, and failed means failed to start
systemctl status mysqld.service
# Start the MySQL service
systemctl start mysqld.service
# Stop MySQL service
systemctl stop mysqld.service
# Restart the MySQL service
systemctl restart mysqld.service
  1. View initial password

The new version of mysql just installed will automatically generate a temporary password and save it in /etc/log/mysqld.log

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

  1. Login with initial password

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

  1. Change the initial password
show databases;
use mysql;
# For example, change the password to NewPassword!, For safety, try to include uppercase and lowercase alphanumerics plus symbols
alter 'user'@'localhost' identified by 'NewPassword!';
  1. Modify access permissions to enable remote connection
update user set Host='%' where User='root' and Host='localhost';
  1. Refresh permissions

flush privileges;

  1. New user
create user username identified by'password'; 
# For example, to create a user and specify the host that can be accessed, and specify the database table and the corresponding permissions that it can access
create user username@'CPU name' identified by 'password';
grant select, update, create,delete on database name.Table name to user name;
  1. Grant permissions, remember to refresh permissions to take effect

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

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

Create a new database first

create database db10;

Import existing database files into 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

to sum up

The above is the tutorial for installing MYSQL8.X in Centos introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message. The editor will reply to you in time. Thank you very much for your support to the ZaLou.Cn website!
If you think this article is helpful to you, welcome to reprint, please indicate the source, thank you!

Recommended Posts

Centos install MYSQL8.X tutorial
Centos install elasticsearch tutorial
Centos7 install kubernetes tutorial
Centos7 install Mysql8 tutorial
Linux Centos7 install redis tutorial
vmware install CentOS 7 detailed tutorial
1.5 Install Centos7
5.1. CentOS@ install JDK1.8 graphic tutorial
CentOS 7 yum install PHP7.3 tutorial
Install Mesos tutorial under CentOS7
Minimal install JDK 1.8 tutorial in CentOS 7
CentOS8 install jdk8 / java8 tutorial (recommended)
Centos6 install Python2.7.13
Centos7.3 install nginx
CentOS install Redmine
Centos7 install Python 3.6.
CentOS7 install MySQL
Centos7 install protobuf
CentOS7 install GlusterFS
CentOS 7.4 install Zabbix 3.4
CentOS7 install Docker
Centos6.5 install Tomcat
CentOS install Python 3.6
Vmware install CentOS6
centos7 install docker-ce 18.01.0
CentOS 7.2 install MariaDB
CentOS 7 install Hadoop 3.0.0
Centos7 install Python2.7
Centos 7.6 install seleniu
CentOS 7.3 install Zabbix3
Centos7 install LAMP+PHPmyadmin
CentOS install mysql
CentOS install openjdk 1.8
CENTOS6.5 install CDH5.12.1 (1)
CentOS install PHP
CentOS6 install mist.io
Centos7 install Docker
CentOS7 install mysql
centOs install rabbitMQ
CentOS 7 install MySQL 5.6
Centos7 install Nginx
CentOS6.5 install CDH5.13
Centos7 install docker18
Centos install Python3
centos7 install docker
CentOS install jdk
centos7 install nginx-rtmp
CentOS8 install MySQL8.0
Centos6.3 install KVM
CentOS install PostgreSQL 9.1
CentOS7 install mysql8
CentOS 7 install Java 1.8
CentOS8 install fastdfs6.06
CentOS 7 install Gitlab
Centos 7 install PostgreSQL
CentOS7 install MySQL8
CentOS 7 install Java 1.8
CentOS 6 install Docker
centos 6.5 install zabbix 4.4
Centos8 install Docker
CentOS6.8 install python2.7