怎么在Linux中修改MySQL数据库数据文件路径-创新互联
今天就跟大家聊聊有关怎么在Linux中修改MySQL数据库数据文件路径,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。
公司主营业务:网站制作、网站建设、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。成都创新互联公司是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。成都创新互联公司推出惠水免费做网站回馈大家。步骤:
1、创建目标路径
mkdir -p /home/mysql_data
2、关闭MySQL
systemctl stop mysqld
3、复制数据文件
cp -arp /var/lib/mysql /home/mysql_data
4、修改配置文件/etc/my.cnf
将datadir和socket中的原路径修改为目标路径
datadir=/home/mysql_data/mysql socket=/home/mysql_data/mysql/mysql.sock
5、启动MySQL服务
systemctl start mysqld
NOTE:
1、报错如下:
2019-12-22T08:32:42.430564Z 0 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2019-12-22T08:32:42.430599Z 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2019-12-22T08:32:42.430616Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2019-12-22T08:32:42.430898Z 0 [ERROR] InnoDB: The innodb_temporary data file 'ibtmp1' must be writable
2019-12-22T08:32:42.430923Z 0 [ERROR] InnoDB: The innodb_temporary data file 'ibtmp1' must be writable
2019-12-22T08:32:42.430936Z 0 [ERROR] InnoDB: Could not create the shared innodb_temporary.
2019-12-22T08:32:42.430952Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2019-12-22T08:32:43.038973Z 0 [ERROR] InnoDB: Operating system error number 13 in a file operation.
2019-12-22T08:32:43.039021Z 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
2019-12-22T08:32:43.039037Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2019-12-22T08:32:43.039046Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2019-12-22T08:32:43.039056Z 0 [ERROR] Failed to initialize builtin plugins.
2019-12-22T08:32:43.039063Z 0 [ERROR] Aborting
解决:
执行命令:
setenforce 1
再重新启动
2、报错如下:
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
解决:
修改配置文件my.cnf,添加或修改如下配置:
[client] socket = /home/mysql_data/mysql/mysql.sock
看完上述内容,你们对怎么在Linux中修改MySQL数据库数据文件路径有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注创新互联行业资讯频道,感谢大家的支持。
当前题目:怎么在Linux中修改MySQL数据库数据文件路径-创新互联
网页路径:http://myzitong.com/article/diepdp.html