Mysql数据迁移

使用linux下的软连接方法,具体操作如下:(以迁移到/home/mysql/目录为例)

先停止mysql:

systemctl stop mysqld

迁移数据
mv /var/lib/mysql/* /home/mysql
创建软连接:

ln -s /home/mysql /var/lib/mysql

修改配置文件

vim /etc/my.cnf

#datadir=/var/lib/mysql
datadir=/data/mysql

#socket=/var/lib/mysql/mysql.sock
socket=/data/mysql/mysql.sock

log-bin=/data/mysql/mysql-bin
修改存贮位置

启动服务

systemctl start mysqld

Mysql报错:[ERROR] mysqld: File ‘./mysql-bin.000011‘ not found (Errcode: 2 “No such file or directory“)

2022-08-11T07:03:44.803393Z 0 [Note] InnoDB: Buffer pool(s) load completed at 220811 15:03:44
mysqld: File '/var/lib/mysql/mysql-bin.000011' not found (Errcode: 2 - No such file or directory)
2022-08-11T07:03:44.805166Z 0 [ERROR] Failed to open log (file '/var/lib/mysql/mysql-bin.000011', errno 2)

解决

将index文件删除(移到/tmp目录下)
在这里插入图片描述
启动mysql即成功。

你可能感兴趣的:(MYSQL,mysql,linux)