Linux MySQL 更改数据存储目录

MySQL Linux CentOS About 367 words

查看当前数据存储目录

select @@datadir;

停止MySQL服务

service mysqld stop

备份datadir

cp /var/lib/mysql /var/lib/mysql.bak

修改存储目录

配置文件中指定存储目录

[client]
socket=/home/mysql/data/mysql.sock

[mysqld]
datadir =/home/mysql/data
socket=/home/mysql/data/mysql.sock

拷贝先前数据

cp -r /var/lib/mysql /home/mysql/data

修改存储目录归属用户

chown -R mysql:mysql /home/mysql/data

重启MySQL服务即可

service mysqld start
Views: 2,478 · Posted: 2019-09-30

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh