MySQL 8.0.25 installation and configuration tutorial under Linux

MySQL 8.0.25 installation and configuration tutorial under Linux

The latest tutorial for installing MySQL 8.0.25 on Linux is for your reference. The specific contents are as follows

I installed MySQL on the server myself and collected a lot of materials, but most of them took a long time. The latest download and installation methods have many differences, and I also stepped on many pitfalls. So I sorted out my entire installation process, and you can refer to it.

download

Online Installation

wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.25-linux-glibc2.12-x86_64.tar.xz

Offline installation

First go to the official website to download the installation file, the latest download

MySQL Download Address

image-20210521164331610

image-20210521164701764

Select the appropriate installation package to download according to the number of server bits

Attached is the Linux command to check the number of bits

getconf LONG_BIT 

image-20210521164701764

image-20210521164701764

Use ftp to upload the installation file

Unzip

tar -xvf mysql-8.0.25-linux-glibc2.12-x86_64.tar.xz

Later, when configuring environment variables and database configuration, the decompression path is too long

Modify the default folder name. I modified it through the ftp tool. The command is attached below.

mv mysql-8.0.25-linux-glibc2.12-x86_64 /home/mysql-8.0.25
#Detailed explanation: mv The folder name where the current file name is modified

Create a data directory

# 1. Create a folder mkdir -p /data/mysqldata/
#2 Create a database user. You will need it for file configuration and initialization later. If you have other users, you don’t need to create a new one. #2.1 Create a user group groupadd mysql
 #2.2 Create user useradd -r -g mysql mysql
#Give permissions 2. chown mysql:mysql -R /data/mysqldata #chown username:usergroup-R /data/mysqldata
3. chmod 750 /data/mysqldata/ -R

Configure the environment

vim /etc/profile 
#If your system does not support vim command, use the following vi /etc/profile
#Edit, add the following code to the last line of the document export PATH=$PATH:your MySQL decompression path/mysql-8.0.25/bin:your MySQL decompression path/mysql-8.0.25/lib 

image-20210521164701764

Edit my.cnf

#1. Edit the my.cnf file vim /etc/my.cnf #or vi /etc/my.cnf 

#2. Press insert to enter edit mode and add the following script [mysql]
# Client default character set default-character-set=utf8mb4
[client]
port=3306
socket=/var/lib/mysql/mysql.sock
[mysqld]
port=3306
server-id=3306
user=mysql
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Set the installation directory of mysql basedir=/home/mysql-8.0.25 # Your own installation path # Set the storage directory of mysql database datadatadir=/data/mysqldata/mysql # The storage path of the database file you created yourself log-bin=/data/mysqldata/mysql/mysql-bin
innodb_data_home_dir=/data/mysqldata/mysql
innodb_log_group_home_dir=/data/mysqldata/mysql
character-set-server=utf8mb4
lower_case_table_names=1
autocommit=1
# 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]
#Set the storage directory of mysql database log and process data log-error=/data/mysqldata/mysql/mysql.log
pid-file=/data/mysqldata/mysql/mysql.pid

Initialize MySQL

1. cd /home/mysql-8.0.25/bin/
2. ./mysqld --defaults-file=/etc/my.cnf --basedir=/home/mysql-8.0.25/ --datadir=/data/mysqldata/mysql --user=mysql --initialize
#Parameter Details --defaults-file=/etc/my.cnf specifies the configuration file (must be placed first, at least before --initialize)
--user=mysql specifies the user (very important)
--basedir=/home/mysql-8.0.25/ specifies the installation directory --datadir=/data/mysqldata/mysql/ specifies the initialization data directory

After initializing the database, a temporary password will be given. Please save it locally. It will be used when you log in to the database for the first time.

image-20210521164701764

Start MySQL

# 1. Copy the mysql.server file cp /home/mysql-8.0.25/support-files/mysql.server /etc/init.d/mysql
cp /home/mysql-8.0.25/support-files/mysql.server /etc/init.d/mysqld
# 2. Grant permissions chown 777 /etc/my.cnf
chmod +x /etc/init.d/mysql
chmod +x /etc/init.d/mysqld
# 3. Check if /var/lib/mysql exists. If not, create it. mkdir /var/lib/mysql #Keep the directory consistent with my.cnf. # 4. Grant permissions. chown -R mysql:mysql /var/lib/mysql/ #Keep the directory consistent with my.cnf. # 5. Start the database. service mysql start #Or systemctl mysql start

Startup Success

image-20210521164701764

mysql database settings

Change the initial password

mysql -u root -p

or

#Enter the installation directory cd /home/mysql-8.0.25/bin
# Execute the command ./mysql -uroot -p

Enter the temporary password saved locally

image-20210521164701764

Change Password

# Change the root password. Change the root user to only be able to connect locally. ALTER USER 'root'@'localhost' IDENTIFIED with mysql_native_password BY 'new password';
#Flush privileges;

Create User

#Create a user for any remote accessCREATE user 'mysql'@'%'; 
#Change password alter user 'mysql'@'%' identified with mysql_native_password by 'new password';

Create a database

create database test default character set utf8mb4 collate utf8mb4_unicode_ci;
#create database database name default character set utf8mb4 collate utf8mb4_unicode_ci;

Authorization

#Grant all privileges on test database to mysql user grant all privileges on test.* to "mysql"@"%";
#Flush privileges;

examine

Use navicat to test whether the database is connected normally

image-20210521164701764

Extension (MySQL starts automatically at boot)

#1. Check if there is mysql service chkconfig --list
#2. Enter the mysql software directory and copy the mysql.server file to the /etc/rc.d/init.d directory cp /home/mysql-8.0.25/support-files/mysql.server /etc/rc.d/init.d/mysql
#3. Grant executable permissions to /etc/rc.d/init.d/mysql chmod +x /etc/rc.d/init.d/mysql
#4. Add mysql service chkconfig --add mysql
#5. Enable mysql service to start automatically at boot time chkconfig --level 345 mysql on
#6. Check the MySQL service, restart the server, and test whether it is successful.
chkconfig --list

Added successfully

image-20210521164701764

For more tutorials about MySQL, please click on the topic: "MySQL different versions installation tutorial"

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

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
  • Tutorial on installing MySQL under Linux
  • MySQL multi-instance deployment and installation guide 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

<<:  Common parameters of IE web page pop-up windows can be set by yourself

>>:  Website Building Tutorial for Beginners: Learn to Build a Website in Ten Days

Recommend

Detailed explanation of React component communication

Table of contents Component Communication Introdu...

Several ways to add timestamps in MySQL tables

Scenario: The data in a table needs to be synchro...

MySQL 8.0.18 installation and configuration method graphic tutorial under MacOS

This article records the installation of MySQL 8....

Test and solution for MySQL's large memory usage and high CPU usage

After the changes: innodb_buffer_pool_size=576M -...

jQuery implements the drop-down box for selecting the place of residence

The specific code for using jQuery to implement t...

MySQL InnoDB monitoring (system layer, database layer)

MySQL InnoDB monitoring (system layer, database l...

Nest.js authorization verification method example

Table of contents 0x0 Introduction 0x1 RBAC Imple...

How to use partitioning to optimize MySQL data processing for billions of data

When MySQL queries tens of millions of data, most...

Win10 installation Linux system tutorial diagram

To install a virtual machine on a Windows system,...

Analysis of the reasons why MySQL's index system uses B+ tree

Table of contents 1. What is an index? 2. Why do ...

Vue uniapp realizes the segmenter effect

This article shares the specific code of vue unia...

Vue2/vue3 routing permission management method example

1. There are generally two methods for Vue routin...

MySQL extracts Json internal fields and dumps them as numbers

Table of contents background Problem Analysis 1. ...

Detailed steps to configure my.ini for mysql5.7 and above

There is no data directory, my-default.ini and my...