“This article has participated in the good article summoning order activity, click to view: back end, big front double track submission, 20,000 yuan prize pool for you to challenge”

I am Chen PI, a Coding ITer in the Internet. Search “Chen PI’s JavaLib” on wechat and read the latest articles at the first time. Reply to [data], you can get my carefully organized technical data, electronic books, interview materials of first-line big factories and excellent resume template.

The introduction

As we all know, there are some major changes and optimizations in MySQL 8.x, so I hope you can check out some of the new features and optimizations in MySQL 8. If you want to install MySQL 8 on a Linux server, you will need to install MySQL 8.

The MySQL 8.x database is installed on a CentOS 7.x Linux server.

Installation steps

Installation package download address: official dev.mysql.com/downloads/m…

Upload the downloaded package to the Linux server and decompress it.

The tar XVF mysql - 8.0.26 - Linux - glibc2.12 - x86_64. Tar. XzCopy the code

Rename the decompressed folder to mysql and move it to /usr/local/.

Mysql - 8.0.26 - Linux - mv glibc2.12 x86_64 / usr/local/mysqlCopy the code

Go to the /usr/local/mysql directory and create the data folder for storing database data.

 cd /usr/local/mysql/
 mkdir data
Copy the code

Create the TMP folder in the mysql directory and change the permissions of the folder.

 mkdir tmp
 chmod 777 /tmp
Copy the code

Create the mysql user group and mysql user, and assign permissions to the mysql directory and all files below to the mysql user.

 groupadd mysql
 useradd -g mysql mysql
 chown -R mysql.mysql /usr/local/mysql/
Copy the code

Run the following command in the mysql directory to initialize the database. After the initialization is successful, the temporary password of the root user is printed. Remember to use it later.

 bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
Copy the code

To modify the configuration information of mysql, open the my.cnf configuration file.

 vim  /etc/my.cnf
Copy the code

The original contents of the my.cnf configuration file are as follows:

[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # Settings user and group are ignored when systemd is used. # If you need to run mysqld under a different user or group, # customize your systemd unit file for mariadb according to the # instructions in http://fedoraproject.org/wiki/Systemd [mysqld_safe] log-error=/var/log/mariadb/mariadb.log pid-file=/var/run/mariadb/mariadb.pid # # include all files from the config directory # ! includedir /etc/my.cnf.dCopy the code

Modify the content of the configuration file as follows:

 [mysqld]
 basedir=/usr/local/mysql   
 datadir=/usr/local/mysql/data
 socket=/usr/local/mysql/mysql.sock
 character-set-server=utf8
 port=3306
 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
 [client]
 socket=/usr/local/mysql/mysql.sock
 default-character-set=utf8
Copy the code

Add mysql.server file to /etc/init.d/ directory and rename it mysql, so we can use the service mysql xx command to start and stop mysql.

 cp ./support-files/mysql.server /etc//init.d/mysql
 chmod +x /etc/init.d/mysql
Copy the code

Register mysql as a service.

 chkconfig --add mysql
Copy the code

Run the chkconfig –list mysql command to check whether the mysql database is successfully registered.

[root@chenpi mysql]# chkconfig --list mysql Note: This output shows SysV services only and does not include native systemd services. SysV configuration data might be overridden by native systemd configuration. If you want to list systemd services use 'systemctl list-unit-files'. To see  services enabled on particular target use 'systemctl list-dependencies [target]'. mysql 0:off 1:off 2:on 3:on 4:on 5:on  6:offCopy the code

Start the service and view the service status.

 [root@chenpi mysql]# service mysql start
 Starting MySQL.Logging to '/usr/local/mysql/data/chenpi.err'.
 . SUCCESS! 
 ​
 [root@chenpi mysql]# service mysql status
  SUCCESS! MySQL running (1622)
Copy the code

Connect the mysql command to the /usr/bin directory.

 ln -s /usr/local/mysql/bin/mysql /usr/bin
Copy the code

Connect to the mysql server and enter the temporary password generated during installation.

 mysql -uroot -p
Copy the code

Change the password.

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new password '; mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456'; Query OK, 0 rows affected (0.02sec)Copy the code

The mysql server is installed as user root.

 use mysql
 update user set host ='%' where user='root';
 FLUSH PRIVILEGES;
Copy the code

Run the exit command to exit the mysql database.