How to migrate the data directory in mysql8.0.20

How to migrate the data directory in mysql8.0.20

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

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

For data migration of version 8.0.11, please see another blog: mysql8.0.11 data migration

1. Stop the mysql service first:

service mysqld 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 /var/lib/ 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:

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

Modified settings:

datadir=/bak/mysql_data/mysql
socket=/bak/mysql_data/mysql/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

5. Restart the mysql service:

service mysqld restart

mysql can start normally and it's OK~

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

For data migration of version 8.0.11, please see another blog: mysql8.0.11 data migration

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

You may also be interested in:
  • Implementation of mysql8.0.11 data directory migration
  • 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

<<:  UTF-8 and GB2312 web encoding

>>:  A line of CSS code that crashes Chrome

Recommend

How to view and modify the time zone in MySQL

Today I found that a program inserted an incorrec...

Installation and configuration method of Zabbix Agent on Linux platform

Here is a brief summary of the installation and c...

Six-step example code for JDBC connection (connecting to MySQL)

Six steps of JDBC: 1. Register the driver 2. Get ...

Vue axios interceptor commonly used repeated request cancellation

introduction The previous article introduced the ...

Docker port mapping and external inaccessibility issues

The Docker container provides services and listen...

What is the function and writing order of the a tag pseudo class

The role of the a tag pseudo-class: ":link&qu...

MySQL Series 13 MySQL Replication

Table of contents 1. MySQL replication related co...

Implementing a simple Gobang game with native JavaScript

This article shares the specific code for impleme...

Case analysis of several MySQL update operations

Table of contents Case Study Update account balan...

Learning about UDP in Linux

Table of contents 1. Introduction to UDP and Linu...

Delete the image operation of none in docker images

Since I usually use the docker build command to g...