Deepin20.1 system installs MySQL8.0.23 (super detailed MySQL8 installation tutorial)

Deepin20.1 system installs MySQL8.0.23 (super detailed MySQL8 installation tutorial)

Download MySQL-8.0.23
Click to download: mysql-8.0.23-linux-glibc2.12-x86_64.tar.xz

mysql-8.0.23-linux-glibc2.12-x86_64.tar.xz

Unzip the MySQL installation package to a directory (here I choose: /usr/local)

sudo tar -Jxv -f /home/×××shanlin/Downloads/mysql-8.0.23-linux-glibc2.12-x86_64.tar.xz -C /usr/local/

Note: /home/×××shanlin/Downloads/ is the directory where my browser saves files

Create a soft link (easy to operate: you can think of it as giving the mysql-8.0.23-linux-glibc2.12-x86_64 directory an alias called mysql)

sudo ln -s /usr/local/mysql-8.0.23-linux-glibc2.12-x86_64 mysql

Create a directory to store MySQL data (/data/mysql/data) and generate the database connection file mysql.sock (/var/run/mysqld)

sudo mkdir -p /data/mysql/data
sudo mkdir -p /var/run/mysqld

Create mysql user group and user

sudo groupadd mysql
sudo useradd -r -g mysql mysql

Grant permissions to the /data/mysql/data and /var/run/mysqld directories

sudo chown mysql:mysql -R /data/mysql/data
sudo chown mysql:mysql -R /var/run/mysqld

Create a my.cnf file and use the which mysqld command to view the location of mysqld: mine is /usr/local/mysql/bin/mysqld, then use the /usr/local/mysql/bin/mysqld --verbose --help |grep -A 1 'Default options' command to view the location where my.cnf can be created:
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf /usr/local/mysql/my.cnf ~/.my.cnf
Check /etc/my.cnf, /etc/mysql/my.cnf, /usr/local/mysql/etc/my.cnf, /usr/local/mysql/my.cnf. If the my.cnf file is not found, create a new my.cnf file in /usr/local/mysql/. The following is the content of the my.cnf file:

[mysqld]
bind-address=0.0.0.0
port=3306
user=mysql
basedir=/usr/local/mysql
datadir=/data/mysql/data
socket=/var/run/mysqld/mysqld.sock
log-error=/data/mysql/data/mysql.err
pid-file=/data/mysql/data/mysql.pid
character_set_server=utf8mb4
symbolic-links=0
explicit_defaults_for_timestamp=true
default_authentication_plugin=mysql_native_password
#Solve the error Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) [client]
port=3306
socket=/var/run/mysqld/mysqld.sock
#Create my.cnf directly with vim and write the above content sudo vim /usr/local/mysql/my.cnf

Configure MySQL environment variables

#mysql 
MYSQL_HOME=/usr/local/mysql
PATH=$PATH:$MYSQL_HOME/bin
export PATH MYSQL_HOME
#Write the above content at the end of the profile file sudo vim /etc/profile
#Environment variables take effect immediately sudo source /etc/profile

Install MySQL

sudo /usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data --initialize

After normal installation, it will finally display:
A temporary password is generated for root@localhost: x2yfhWE>0FiR (after the colon is a random password, different for everyone)
Remember the random password after the colon

Start MySQL service

sudo /usr/local/mysql/support-files/mysql.server start

Put the MySQL process into the system process

sudo cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

Create a soft link to MySQL in /usr/bin

sudo ln -s /usr/local/mysql/bin/mysql /usr/bin

Log in to MySQL database using a random password

mysql -u root -p

Set a new password for the root user

alter user 'root'@'localhost' identified by '123456';

This is the end of this article about installing MySQL 8.0.23 on deepin 20.1 system (the most domestically produced Liunx system, the most detailed MySQL 8 installation tutorial). For more relevant content about installing MySQL 8.0.23 on deepin 20.1 system, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Complete step-by-step record of MySQL 8.0.26 installation and uninstallation
  • mysql8.0.23 linux (centos7) installation complete and detailed tutorial
  • MySQL 8.0.23 installation super detailed tutorial
  • MySQL 8.0.22 decompression version installation tutorial (for beginners only)
  • MySQL 8.0.26 installation and simplified tutorial (the most complete on the Internet)

<<:  How to deploy Rancher with Docker (no pitfalls)

>>:  Share CSS writing standards and order [recommended for everyone to use]

Recommend

Detailed steps for debugging VUE projects in IDEA

To debug js code, you need to write debugger in t...

Detailed explanation of Nginx Rewrite usage scenarios and code examples

Nginx Rewrite usage scenarios 1. URL address jump...

Analysis and solution of Chinese garbled characters in HTML hyperlinks

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

Teach you a trick to achieve text comparison in Linux

Preface In the process of writing code, we will i...

Steps for Docker to build its own local image repository

1. Environment and preparation 1. Ubuntu 14.04 2....

MySQL Installer Community 5.7.16 installation detailed tutorial

This article records the detailed tutorial of MyS...

Some issues we should pay attention to when designing a web page

Web design, according to personal preferences and ...

Website Color Schemes Choosing the Right Colors for Your Website

Does color influence website visitors? A few year...

Vue+express+Socket realizes chat function

This article shares the specific code of Vue+expr...

How to build php7 with docker custom image

First, perform a simple Docker installation. To c...

Parsing the commonly used v-instructions in vue.js

Table of contents Explanation of v-text on if for...