Tutorial on installing MySQL under Linux

Tutorial on installing MySQL under Linux

Preface:

The previous article introduced the MySQL installation tutorial under Windows in detail. This article starts with the most basic installation of MySQL-Linux environment. Interested friends can follow me. The series of articles will be continuously updated. Come on, let's make progress together!

1. Delete the old version

Check whether the server has built-in MySQL . If so, you can use it directly. If the built-in version is lower, you can delete it and install the version you want (before installing the new version of MySQL, you need to uninstall the server's built-in MySQL package and the MySQL database branch mariadb package)

rpm -qa|grep mysql -- Check whether the server has mysql . If yes, execute the following statement to delete it.

rpm -qa |grep mariadb -- Check whether the server has mariadb . If yes, execute step 3 to delete it.

rpm -e --nodeps file name to be deleted (nodeps means forced deletion)

2. Check the server kernel type, download the appropriate version and upload it to the server

2.1. Use cat /proc/version to view the kernel type of the system

2.2. Download the appropriate type from the official website

2.3. Upload to the server via rz command or xftp tool

Note: If the command cannot be found when using the rz command, directly execute: yum -y install lrzsz to download it online.

Command: rz or rz -be

Format: rz -be Select the file to upload

Upload files in batches or individually through the ZMODEM protocol. In addition, you can also upload via ftp or sftp

Note: If you think that uploading via the rz command takes a long time, you can download an xftp tool, which is more efficient (this article will not expand on this tool. If you need it, you can leave a message below. A detailed introduction will be published later.)

3. Unzip and install the corresponding components step by step

3.1. Decompression command

tar -xvf the file name to be decompressed -C the path to be compressed (-C and the following parameters can be omitted)

3.2. Install component command: rpm -ivh component name to be installed

Follow the following command sequence and change the file name to the name of the compressed file.

//mysql-community-common
1. rpm -ivh mysql-community-common-8.0.16-2.el7.x86_64.rpm

//mysql-community-libs
2. rpm -ivh mysql-community-libs-8.0.16-2.el7.x86_64.rpm --force --nodeps

//mysql-community-libs-compat
3. rpm -ivh mysql-community-libs-compat-8.0.16-2.el7.x86_64.rpm

//mysql-community-client
4. rpm -ivh mysql-community-client-8.0.16-2.el7.x86_64.rpm --force --nodeps

//mysql-community-server
5. rpm -ivh mysql-community-server-8.0.16-2.el7.x86_64.rpm --force --nodeps

// View installed components 6. rpm -qa | grep mysql

3.3. Start the MySQL server. If an error occurs, proceed to step 4.

Start command: systemctl start mysql

3.4. If the following error is reported during startup, perform the corresponding steps to repair it

Error message: Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details .

According to the error information, run the "systemctl status mysqld.service" or "journalctl -xe" command to view the error details. You will find that the error information contains: Data Dictionary upgrade from MySQL 5.7 in progress.

The explanation is that there is a conflict between the new version and the previous version of the server. Just delete the corresponding conflicting directory and execute: rm -rf /var/lib/mysql/* (be careful when executing the deletion command)

3.5. Execute after repair is completed

systemctl start mysql starts the MySQL service

4. Connect to MySQL service and change password

The first time you successfully start MySQL, a default password will be set. Use the following command to view and log in.

  • View the temporary password for the first startup: grep password /var/log/mysqld.log
  • Connect to the server: mysql -u root -p Enter, then enter the password
  • The first connection will force you to change the connection password. You can use the following statement to change the password:

ALTER USER root@localhost IDENTIFIED WITH caching_sha2_password BY '123456'; (MySQL 8.x is suitable for this statement)

UPDATE USER SET PASSWORD=PASSWORD('your password') WHERE USER='root'; (modification of MySQL 5.x version)

This is the end of this article about installing MySQL under Linux. For more information about installing MySQL under Linux, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Tutorial on installing mysql5.7.36 database in Linux environment
  • Introduction to the process of installing MySQL 8.0 in Linux environment
  • Detailed steps to install MySQL 8.0.27 in Linux 7.6 binary
  • MySQL multi-instance deployment and installation guide under Linux
  • MySQL 8.0.25 installation and configuration tutorial under Linux
  • mysql8.0.23 linux (centos7) installation complete and detailed tutorial
  • Detailed tutorial on installing MySQL database in Linux environment
  • Detailed tutorial on installing mysql-8.0.20 under Linux
  • Linux system MySQL8.0.19 quick installation and configuration tutorial diagram
  • Tutorial on installing mysql8 on linux centos7
  • Install MySQL database in Linux environment

<<:  How to use display:olck/none to create a menu bar

>>: 

Recommend

How to View All Running Processes in Linux

You can use the ps command. It can display releva...

Detailed explanation of the process of using GPU in Docker

Table of contents Download tf-gpu Build your own ...

Summary of uncommon operators and operators in js

Summary of common operators and operators in java...

How to deploy gitlab using Docker-compose

Docker-compose deploys gitlab 1. Install Docker I...

A brief discussion on the difference between src and href in HTML

Simply put, src means "I want to load this r...

Advantages and Problems of XHTML CSS Website Design

XHTML is the standard website design language cur...

How to choose the format when using binlog in MySQL

Table of contents 1. Three modes of binlog 1.Stat...

Analysis and solution of Chinese garbled characters in HTML hyperlinks

A hyperlink URL in Vm needs to be concatenated wit...

MySQL character set garbled characters and solutions

Preface A character set is a set of symbols and e...

JavaScript implements cool mouse tailing effects

After watching this, I guarantee that you have ha...

A complete guide on how to query and delete duplicate records in MySQL

Preface This article mainly introduces the method...

Design and implementation of Vue cascading drop-down box

Table of contents 1. Database design 2. Front-end...

Detailed explanation of monitoring NVIDIA GPU usage under Linux

When using TensorFlow for deep learning, insuffic...

Mysql timeline data to obtain the first three data of the same day

Create table data CREATE TABLE `praise_info` ( `i...

Detailed explanation of the use of title tags and paragraph tags in XHTML

XHTML Headings Overview When we write Word docume...