MySQL 8.0 installation, deployment and configuration under CentOS 6/7

I. Introduction##

1、 Scope of this tutorial###

Software Version
CentOS CentOS 6 & CentOS 7
MySQL 8.0.x

2、 Environmental information of this article###

Software Version
CentOS 7.4 Release
MySQL 8.0.11

Second, install##

1、 Add package###

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

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

2、 installation###

# installation
sudo yum -y install mysql-community-server

# Start service
sudo systemctl start mysqld

# View version information
mysql -V

3、 Root account password modification###

#1、 View the temporary password generated by MySQL for the Root account
grep "A temporary password"/var/log/mysqld.log

#2、 Enter MySQL shell
mysql -u root -p

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

4、 Open port###

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

# Reload firewall settings
firewall-cmd --reload

# CentOS 6
iptables -I INPUT -p tcp --dport 3306-j ACCEPT

iptables save

Three, MySQL security settings##

Enter the security setup wizard

mysql_secure_installation

Security settings are roughly divided into the following steps

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

The following are examples of security settings;

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!

Fourth, users & permissions##

1、 Create User & Database (mysql-shell)

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

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

# New database
CREATE DATABASE testdb;

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

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

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

# Refresh permissions
FLUSH PRIVILEGES;

2、 Permission example (mysql-shell)

#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

Recommended Posts

MySQL 8.0 installation, deployment and configuration under CentOS 6/7
Centos mysql installation and configuration
MySQL 8.0 installation and deployment under CentOS, super detailed!
MySQL 8.0 installation, deployment and configuration tutorial on CentOS 8
Java-JDK installation and configuration under CentOS
Erlang 20.2 installation and deployment under CentOS 7
Centos7 mysql database installation and configuration
Mysql8.0.15 installation configuration (centos7)
Installation and use of Mysql under CentOS
Tomcat installation and configuration under CentOS 7 (Tomcat startup)
Installation and configuration of redis under centos7
Zabbix installation and deployment and localization under CentOS
Jenkins installation and deployment tutorial under CentOS 7
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
CentOS 7 installation and configuration graphic tutorials under VMware10
Installation and configuration of rsync server under CentOS 6.5
Environment configuration of JDK, mysql and tomcat under Centos7
Centos7 installation and configuration of Jenkins
Centos6.5 installation and deployment of KVM
Centos7 hadoop cluster installation and configuration
CentOS 7 Tomcat service installation and configuration
CentOS NTP server installation and configuration
CentOs7 installation and deployment Zabbix3.4 original
Centos MySQL8 configuration
Detailed explanation of Spark installation and configuration tutorial under centOS7
CentOS 7 system installation and configuration graphic tutorial
Centos-6.5 installation and deployment of LNMP environment
Centos7 installation and deployment of gitlab server
Centos7 hive stand-alone mode installation and configuration
KVM installation and preliminary use under CentOS 7.2
DLNA/UPnP Server installation and configuration under Ubuntu 12.04
Centos7 installation and deployment of Airflow detailed
OpenMPI-Ubuntu installation and configuration
Install mysql under Centos 7
Redis3 installation under Centos7
Install mysql5.1 under CentOS6.5
CentOS 6.5 system installation and configuration graphic tutorial (detailed graphic)
Install svn and configuration through yum under CentOS
Kaldi installation and configuration graphic tutorials under Ubuntu
Installation and configuration of CentOS 7 in VMware Workstation
Installing CentOS 6 and SSH configuration under Windows 8 Hyper-V
Distributed deployment of Apollo configuration center under CentOS8
[CentOS environment deployment] Java7/Java8 deployment under CentOS
Installation and cracking of confluence6.3 operation records under Centos
Ubuntu16.04 mirror complete installation and configuration tutorial under VMware
Centos7.4 deployment configuration Elasticsearch5.6 cluster
Redis cluster installation under CentOS
Installation and cracking of Jira7 operation records under Centos
Ubuntu16.04 installation and simple configuration
CentOS 6.x installation mysql5.7 record
Install MySQL under Linux (CentOS 7)
Redis cluster installation under CentOS
centos7 kvm installation and use
CentOS mysql configuration master-slave replication
CentOS7 postgresql installation and use
Ubuntu PostgreSQL installation and configuration
Centos7 elk7.1.1 installation and use