mysql修改安装路径,安装好后不能启动,mysqld和mysql_safe中路径错误

问答中心分类: Databasemysql修改安装路径,安装好后不能启动,mysqld和mysql_safe中路径错误
lxy126 asked 8 年 ago
在options.conf中修改了mysql的安装路径,运行install.sh进行安装,安装好后不能启动mysql,新目录为/opt/lnmp5/mysql和/opt/lnmp5/mysql_data,参看my.cnf和mysqld_safe、mysqld3个文件,发现在mysqld中,basedir=/opt/lnmp5/mysql ;datadir=/opt/lnmp5/mysql_data,但是
mysqld_pid_file_path=
if test -z "$basedir"
then
basedir=/usr/local/mysql
bindir=/usr/local/mysql/bin
if test -z "$datadir"
then
datadir=/usr/local/mysql/data
fi
sbindir=/usr/local/mysql/bin
libexecdir=/usr/local/mysql/bin
仍然是默认路径,同样在mysqld_safe中,basedir=/opt/lnmp5/mysql ;datadir=/opt/lnmp5/mysql_data,

if echo '/usr/local/mysql/share' | grep '^/usr/local/mysql' > /dev/null
then
relpkgdata=`echo '/usr/local/mysql/share' | sed -e 's,^/usr/local/mysql,,' -e 's,^/,,' -e 's,^,./,'`
else
# pkgdatadir is not relative to prefix
relpkgdata='/usr/local/mysql/share'
fi
case "$0" in
/*)
MY_PWD='/usr/local/mysql'
仍是默认路径。

4 Answers
oneinstack answered 8 年 ago
报什么错误

lxy126 answered 8 年 ago
报错信息是找不到/usr/local/mysql/bin/mysqld,实际路径为/opt/lnmp5/mysql/bin/mysqld。
经过多次重复调整安装,基本确认问题是mysql安装包选择二进制模式安装导致的路径不能完全变更,选址编译模式安装目录变更正常。

oneinstack answered 8 年 ago
sed -i 's@/usr/local/mysql@/opt/lnmp5/mysql@g' /opt/lnmp5/mysql/bin/mysqld_safe

lxy126 answered 8 年 ago
在include/mysql-5.*.sh中添加2条
sed -i 's@/usr/local/mysql@/opt/lnmp5/mysql@g' /etc/init.d/mysqld
sed -i 's@/usr/local/mysql@/opt/lnmp5/mysql@g' /opt/lnmp5/mysql/bin/mysqld_safe
二进制和编译模式安装在没报错,问题解决,谢谢管理员。