Linux下修改MySQL数据库数据文件路径的步骤
作者:虫文儿~ 时间:2024-01-19 13:53:41
使用rpm安装方式安装完MySQL数据库后,数据文件的默认路径为/var/lib/mysql,然而根目录并不适合用于存储数据文件。
原路径:/var/lib/mysql
目标路径:/home/mysql_data/mysql
Linux系统版本:centos7.6
MySQL数据库版本:5.7.25
步骤:
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数据库数据文件路径网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!
来源:https://www.cnblogs.com/Lans-word/archive/2019/12/22/12080177.html
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
SqlServer 2005 T-SQL Query 学习笔记(2)
Python中turtle库常用代码汇总
![](https://img.aspxhome.com/file/2023/9/72859_0s.png)
SQL Server误区30日谈 第17天 有关页校验和的误区
Django+boostrap 美化admin后台的操作
![](https://img.aspxhome.com/file/2023/3/71503_0s.jpg)
Codeigniter控制器controller继承问题实例分析
详解Python实现进度条的4种方式
![](https://img.aspxhome.com/file/2023/4/134814_0s.gif)
python shutil操作文件实例讲解
如何查询Top N及Top(M―N)记录?
一文吃透Go的内置RPC原理
![](https://img.aspxhome.com/file/2023/6/103736_0s.png)
如何用Python进行回归分析与相关分析
![](https://img.aspxhome.com/file/2023/2/69582_0s.png)
python threading模块操作多线程介绍
sqlserver中将varchar类型转换为int型再进行排序的方法
如何安装2019Pycharm最新版本(详细教程)
![](https://img.aspxhome.com/file/2023/6/118356_0s.png)
五个简单有效的Python清理数据脚本分享
![](https://img.aspxhome.com/file/2023/8/124118_0s.jpg)
Go语言的type func()用法详解
Python如何使用函数做字典的值
常用ASP自定义函数集 (S.Sams)
Blender Python编程创建发光材质示例详解
![](https://img.aspxhome.com/file/2023/7/128517_0s.png)
python+jinja2实现接口数据批量生成工具
![](https://img.aspxhome.com/file/2023/4/84944_0s.png)