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

Vue uses mixins to optimize components

Table of contents Mixins implementation Hook func...

Tutorial for installing MySQL 8.0.18 under Windows (Community Edition)

This article briefly introduces how to install My...

Installation of Docker CE on Ubuntu

This article is used to record the installation o...

Example of how to configure nginx in centos server

Download the secure terminal MobaXterm_Personal F...

Implement a simple data response system

Table of contents 1. Dep 2. Understand obverser 3...

Vue routing returns the operation method of restoring page status

Route parameters, route navigation guards: retain...

Vue uses monaco to achieve code highlighting

Using the Vue language and element components, we...

Some tips for writing high-performance HTML applications

How can you improve web page performance? Most de...

Application scenarios and design methods of MySQL table and database sharding

Many friends have asked in forums and message are...

Summary of three rules for React state management

Table of contents Preface No.1 A focus No.2 Extra...

Design: A willful designer

<br />Years of professional art design educa...

How to implement input checkbox to expand the click range

XML/HTML CodeCopy content to clipboard < div s...

10 content-related principles to improve website performance

<br />English address: http://developer.yaho...

Example of using MySQL to count the number of different values ​​in a column

Preface The requirement implemented in this artic...