Implementation of mysql8.0.11 data directory migration

Implementation of mysql8.0.11 data directory migration

The default storage directory of mysql is /var/lib/mysql/ . The following will modify the default storage directory.

This article uses MySQL 8.0.11, which is different from MySQL 8.0.20.

For data migration of version 8.0.20, please see another blog: mysql8.0.20 data migration

1. Stop the mysql service first:

service mysql stop

2. Create the directory location where you need to store it and grant permissions:

mkdir -p /bak/mysql_data
chmod 766 /bak/mysql_data

3. Transfer the original data. Use cp -a to copy it (first enter the default directory /usr/local/ and copy the entire mysql directory):

cp -a mysql /bak/mysql_data/

4. Modify the mysql configuration file /etc/my.cnf:

vim /etc/my.cnf

Original settings:

[client]
port=3306
socket=/tmp/mysql.sock
 
[mysqld]
port=3306
user=mysql
socket=/tmp/mysql.sock
basedir=/usr/local/mysql/mysql8.0
datadir=/usr/local/mysql/mysql8.0/data
lc-messages-dir = /usr/local/mysql/mysql8.0/share
character-set-server=utf8

Modified settings:

[client]
port=3306
socket=/tmp/mysql.sock
 
[mysqld]
port=3306
user=root
socket=/tmp/mysql.sock
basedir=/usr/local/mysql/mysql8.0
datadir=/bak/mysql_data/mysql/mysql8.0/data
lc-messages-dir = /usr/local/mysql/mysql8.0/share
character-set-server=utf8

This involves a permission issue, and the user needs to be changed to root

5. Restart the mysql service:

service mysql restart

mysql can start normally and it's OK~

If the problem "The server quit without updating PID file(…)" appears during startup, please refer to another blog:

This article uses MySQL 8.0.11, which is different from MySQL 8.0.20.

For data migration of version 8.0.20, please see another blog: mysql8.0.20 data migration

This is the end of this article about the implementation of MySQL 8.0.11 data directory migration. For more relevant MySQL data directory migration content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • How to migrate the data directory in mysql8.0.20
  • Analysis of the principle of MySQL large table extraction mode from the perspective of cloud data migration service
  • How to migrate local mysql to server database
  • Detailed explanation of MySQL event modification events (ALTER EVENT), disabling events (DISABLE), enabling events (ENABLE), event renaming and database event migration operations
  • Upgrade Docker version of MySQL 5.7 to MySQL 8.0.13, data migration
  • Detailed explanation of how to migrate a MySQL database to another machine
  • MySQL database migration quickly exports and imports large amounts of data
  • Python makes mysql data migration script
  • Summary of MySQL data migration

<<:  Three useful codes to make visitors remember your website

>>:  CSS: visited pseudo-class selector secret memories

Recommend

MySQL 5.7.17 installation and configuration method graphic tutorial under win7

I would like to share with you the graphic tutori...

Detailed steps for installing and configuring mysql 5.6.21

1. Overview MySQL version: 5.6.21 Download addres...

Steps to create your own YUM repository

To put it simply, the IP of the virtual machine u...

Detailed explanation of the wonderful CSS attribute MASK

This article will introduce a very interesting at...

How to install Element UI and use vector graphics in vue3.0

Here we only focus on the installation and use of...

How to reset the root password of Mysql in Windows if you forget it

My machine environment: Windows 2008 R2 MySQL 5.6...

Detailed explanation of how Nginx works

How Nginx works Nginx consists of a core and modu...

18 Web Usability Principles You Need to Know

You can have the best visual design skills in the...

Solution to secure-file-priv problem when exporting MySQL data

ERROR 1290 (HY000) : The MySQL server is running ...

JS implements a simple brick-breaking pinball game

This article shares the specific code of JS to im...

Usage of the target attribute of the html tag a

1: If you use the tag <a> to link to a page,...

Detailed explanation of the middleman mode of Angular components

Table of contents 1. Middleman Model 2. Examples ...

Docker primary network port mapping configuration

Port Mapping Before the Docker container is start...

How to add a disk in Vmware: Expand the disk

This article describes how to add or expand a dis...