MySQL 8.0 installation, deployment and configuration tutorial on CentOS 8

I. Introduction##

1、 Main content of this tutorial###

2、 Environmental information and scope of application of this tutorial###

Software Version
CentOS 8.2 Release
MySQL 8.0.21
Software Version
CentOS CentOS 8
MySQL 8.0.21+

Second, install##

1、 Add package###

# CentOS 7
cd /home/downloads
wget https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm
sudo rpm -ivh mysql80-community-release-el8-1.noarch.rpm

2、 installation###

# installation
sudo yum install -y mysql-server

# Start service
sudo systemctl start mysqld

# View version information
mysql -V

# mysql  Ver 8.0.21for Linux on x86_64(Source distribution)

3、 Root account password modification###

#1、 Enter MySQL shell without password
mysql -u root

#2、 change Password
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Mypwd123!';

4、 Open port###

# Open port
firewall-cmd --add-port=3306/tcp --permanent

# Reload firewall settings
firewall-cmd --reload

Three, MySQL security settings##

1、 Introduction to MySQL 8 Security Settings###

MySQL 8 adds a new security setting wizard, which simplifies the operation of security settings for deploying MySQL on the server, which is great.

Security settings are roughly divided into the following steps/options

  1. Password strength verification plugin
  2. Modify root account password
  3. Remove anonymous users
  4. Disable root account remote login
  5. Remove the test database (test)
  6. Reload authorization form

The above steps/options can be done according to your needs.

2、 MySQL 8 security settings example###

mysql_secure_installation
Securing the MySQL server deployment.

Enter password for user root: 

The existing password for the user account root has expired. Please set a newpassword.

New password: 

Re-enter newpassword: 

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: N
Using existing password for root.
Change the password for root ?((Press y|Y for Yes, any other key for No): Y

New password: 

Re-enter newpassword: 
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users?(Press y|Y for Yes, any other key for No):... skipping.

Normally, root should only be allowed to connect from'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely?(Press y|Y for Yes, any other key for No): N

 ... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.

Remove test database and access to it?(Press y|Y for Yes, any other key for No): N

 ... skipping.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now?(Press y|Y for Yes, any other key for No): Y
Success.

All done!

Four, MySQL shell management syntax example##

1、 Examples of database-related syntax###

# Create database
mysql> CREATE DATABASE mydb;

# View all databases
mysql> SHOW DATABASES;

# Use data and create tables
mysql> USE mydb;
mysql> CREATE TABLE test(id int,body varchar(100));

# View table
mysql> SHOW TABLES;

2、 User and access authorization syntax example###

# New local user
mysql> CREATE USER 'test'@'localhost' IDENTIFIED BY '123456';

# New remote user
mysql> CREATE USER 'test'@'%' IDENTIFIED BY '123456';

# Grant the specified account the remote access authority to the specified database
mysql> GRANT ALL PRIVILEGES ON mydb.* TO 'test'@'%';

# Grant the specified account remote access permissions to all databases
mysql> GRANT ALL PRIVILEGES ON *.* TO 'test'@'%';

# Give the specified account local access to all databases
mysql> GRANT ALL PRIVILEGES ON *.* TO 'test'@'localhost';

# Refresh permissions
mysql> FLUSH PRIVILEGES;

3、 Authorization related syntax example###

#1、 View permissions
SHOW GRANTS FOR 'test'@'%';

#2、 Grant permissions
GRANT ALL PRIVILEGES ON *.* TO 'test'@'%';

#3、 Withdraw permission
REVOKE ALL PRIVILEGES ON *.* FROM 'test'@'%';

#4、 Refresh permissions
FLUSH PRIVILEGES;

#5、 delete users
DROP USER 'test'@'localhost';

Five, modify character encoding##

1、 Find the configuration file location###

[ root@centos7 download]# whereis my.cnf
my:/etc/my.cnf

2、 Modify the configuration file###

# Modify the configuration file
vi /etc/my.cnf

# Modification 1: Add client configuration (beginning of file)
[ client]default-character-set=utf8mb4

# Modification 2: Add mysqld configuration (end of file)
# charset
character-set-server=utf8mb4
collation-server=utf8mb4_general_ci

3、 Restart mysql service###

# The configuration will take effect after restart
systemctl restart mysqld

Six, remarks##

Related Reading###

http://www.infoq.com/cn/articles/in-mysql-never-use-utf8-use-utf8

https://serverfault.com/questions/139323/how-to-bind-mysql-server-to-more-than-one-ip-address

Recommended Posts

MySQL 8.0 installation, deployment and configuration tutorial on CentOS 8
MySQL 8.0 installation, deployment and configuration under CentOS 6/7
Centos7 mysql database installation and configuration
CentOS 7 system installation and configuration graphic tutorial
Mysql8.0.15 installation configuration (centos7)
Jenkins installation and deployment tutorial under CentOS 7
CentOS 6.5 system installation and configuration graphic tutorial (detailed graphic)
MySQL 8.0 installation and deployment under CentOS, super detailed!
Centos7 installation and configuration prometheus
CentOS 7 installation and configuration PPTP
CentOS installation and configuration cmake
Centos7.5 installation and configuration MongoDB4.0.4
CentOS 7 installation and configuration PPTP
Centos7 installation and configuration of Jenkins
Centos6.5 installation and deployment of KVM
Java-JDK installation and configuration under CentOS
CentOS 7 Tomcat service installation and configuration
CentOS NTP server installation and configuration
CentOs7 installation and deployment Zabbix3.4 original
Erlang 20.2 installation and deployment under CentOS 7
[Switch] CentOS7 64-bit installation mysql tutorial
Detailed explanation of Spark installation and configuration tutorial under centOS7
Centos8 minimal deployment and installation of OpenStack Ussuri detailed tutorial
Centos MySQL8 configuration
Installation and use of Mysql under CentOS
Tomcat installation and configuration under CentOS 7 (Tomcat startup)
Centos-6.5 installation and deployment of LNMP environment
Installation and configuration of redis under centos7
Centos7 installation and deployment of gitlab server
Zabbix installation and deployment and localization under CentOS
Centos7 hive stand-alone mode installation and configuration
CentOS7 installation zabbix 4.0 tutorial (graphics and text)
Detailed tutorial on installing MySQL 8 in CentOS 7
Centos7 installation and deployment of Airflow detailed
Using Elastic Stack on CentOS 8: Deployment and authentication configuration of Elasticsearch/Kibana 7.8
Installation and configuration of JDK in CentOS 7 system
Xfs configuration on centos7
OpenMPI-Ubuntu installation and configuration
Technical Corner | Using Elastic Stack on CentOS 8: Elasticsearch/Kibana 7.8 Deployment and Authentication Configuration
Centos7 install Mysql8 tutorial
CentOS 7 installation and configuration graphic tutorials under VMware10
Centos7 installation of PHP and Nginx tutorial detailed
How to install jdk1.8.0_151 and mysql5.6.38 on centos7.2.1511
Installation and configuration of CentOS 7 in VMware Workstation
Linux CentOS 7 installation tutorial
Ubuntu16.04 mirror complete installation and configuration tutorial under VMware
Environment configuration of JDK, mysql and tomcat under Centos7
Detailed tutorial on installing JDK8 on Linux system (CentOS7 installation)
Glusterfs cluster installation on Centos7
Ubuntu16.04 installation and simple configuration
Deployment of graphite on centos7
CentOS 6.x installation mysql5.7 record
centos7 kvm installation and use
CentOS mysql configuration master-slave replication
Centos7.4 environment installation lamp-php7.0 tutorial
Ubuntu PostgreSQL installation and configuration
Docker EE installation on centos7
Centos7 elk7.1.1 installation and use
Introduction to CentOS7 installation process of openjdk, tomcat and mysql
How to install MySQL on CentOS 8
CentOS7 yum install and start mysql