迁移MySQL的数据库目录,其实并不难呀
-
查看MySQL数据存放目录
show variables like ‘%dir%’; datadir的值就是mysql当前的存放目录,默认是/usr/local/mysql/data
-
进行迁移
service mysqld stop cp -r /usr/local/mysql/data/* /path/to/mypath
-
修改配置
chown mysql:mysql -R /path/to/mypath
# 修改/etc/my.cnf文件和/etc/init.d/mysqld文件,
将datadir的值更改为新目录
4. 重启服务
service mysqld start
评论 · Comments
评论由 Giscus 提供,需用 GitHub 账号登录;留言会同步到这个仓库的 Discussions 里。