MySQL修改Undo表空间存储目录

本文详细记录了如何在MySQL中更改undo表空间的存储位置,包括检查当前目录、停止服务、创建新目录、移动文件、修改配置参数及重启服务,确保迁移过程顺利进行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、查询源undo表空间目录

mysql[(none)]>show variables like 'innodb_undo%';
+--------------------------+-------+
| Variable_name            | Value |
+--------------------------+-------+
| innodb_undo_directory    | ./    |
| innodb_undo_log_encrypt  | OFF   |
| innodb_undo_log_truncate | ON    |
| innodb_undo_tablespaces  | 2     |
+--------------------------+-------+

2、停止MySQL

systemctl stop mysqld

3、创建新undo表空间目录

[root@ct76mysql80 data]# pwd
/usr/local/mysql/data
[root@ct76mysql80 data]# mkdir undo_file
[root@ct76mysql80 data]# chown -R mysql.mysql undo_file
[root@ct76mysql80 data]# chmod -R 755 undo_file
[root@ct76mysql80 data]# ls -ld undo_file
drwxr-xr-x. 2 mysql mysql 4096 May 22 21:13 undo_file

4、移动undo表空间到新目录下

-rw-r-----. 1 mysql mysql 11534336 May 22 21:14 undo_001
-rw-r-----. 1 mysql mysql 11534336 May 22 21:14 undo_002
drwxr-xr-x. 2 mysql mysql     4096 May 22 21:13 undo_file
[root@ct76mysql80 data]# mv undo_00* undo_file
[root@ct76mysql80 data]# ls -l undo_file/
total 22528
-rw-r-----. 1 mysql mysql 11534336 May 22 21:14 undo_001
-rw-r-----. 1 mysql mysql 11534336 May 22 21:14 undo_002

5、修改undo表空间存储位置参数

innodb_undo_directory = ./undo_file

6、启动MySQL再次查询undo表空间位置

systemctl restart mysqld

[root@ct76mysql80 data]# mysql -uroot -proot
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.20 MySQL Community Server - GPL

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql[(none)]>show variables like 'innodb_undo%';
+--------------------------+-------------+
| Variable_name            | Value       |
+--------------------------+-------------+
| innodb_undo_directory    | ./undo_file |
| innodb_undo_log_encrypt  | OFF         |
| innodb_undo_log_truncate | ON          |
| innodb_undo_tablespaces  | 2           |
+--------------------------+-------------+
4 rows in set (0.01 sec)
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值