Home > Database > Mysql Tutorial > body text

mysql数据存储目录迁移小记_MySQL

WBOY
Release: 2016-05-31 08:47:32
Original
1341 people have browsed it

背景:

因刚开始安装mysql的时候没有考虑后期磁盘分区空间问题,所以mysql的数据保存目录就按安装默认的目录/usr/local/mysql/(我下载的是一个lamp一键安装包安装的mysql),现在随着服务的运行发现/usr/local/mysql所在分区空间使用快接近100%了,怎么办?不想重装mysql,我服务器大部分空间mount在/app下了,于想想到了linux下的ln -s命令

OK 下面开操作了(注:以下操作均在零晨1点操作,记住先将数据备份成sql文件):

1. service mysqld stop2. 在/app 下新建一个目录mysqldir : mkdir mysqldir #在新分区上建立mysqldir目录3. cd /usr/local/mysql && cp -r /app/mysqldir 新数据拷到新目录mysqldir下4. rm -rf mysql//把原来的数据目录删掉5 ln -s /app/mysqldir mysql6. service mysqld start
Copy after login

本以为没啥问题,运行第6条命令后发现mysql起不来,所如下错误:

Starting MySQL. ERROR! The server quit without updating PID file (/usr/local/mysql/data/AY13121220352352963dZ.pid).
Copy after login

运行service mysqld status输出如下提示信息:

ERROR! MySQL is not running, but lock file (/var/lock/subsys/mysql) exists
Copy after login

ok 这个问题应该很常见了,我的解决办法是运行如下命令:

1. chown -R mysql:mysql /app/mysqldir #设置新目录权限归mysql用户所有2. rm -f /var/lock/subsys/mysql
Copy after login

再执行service mysqld start 大功告成

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!