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

Horizontal header menu implemented with CSS3

Result:Implementation Code html <nav class=&qu...

js+Html to realize table editable operation

This article shares the specific code of js+Html ...

Analysis of Sysbench's benchmarking process for MySQL

Preface 1. Benchmarking is a type of performance ...

How to install and configure GitLab on Ubuntu 20.04

introduce GitLab CE or Community Edition is an op...

18 Amazing Connections Between Interaction Design and Psychology

Designers need to understand psychology reading n...

Docker data management and network communication usage

You can install Docker and perform simple operati...

Detailed analysis of binlog_format mode and configuration in MySQL

There are three main ways of MySQL replication: S...

Detailed explanation of downloading, installing and using nginx server

download http://nginx.org/en/download.html Unzip ...

How to call the interrupted system in Linux

Preface Slow system calls refer to system calls t...

Example code of how to implement pivot table in MySQL/MariaDB

The previous article introduced several methods f...

How to write beautiful HTML code

What Beautiful HTML Code Looks Like How to write ...

Detailed explanation of non-parent-child component communication in Vue3

Table of contents First method App.vue Home.vue H...