今天安装mysql5.0在配置开机自启动时,把安装目录中的文件mysql.server.sh复制为/etc/init.d/mysql
之后启动/etc/init.d/mysql start时出错以下错误:
/etc/init.d/mysqld: line 237: my_print_defaults: command not found
/etc/init.d/mysqld: line 240: my_print_defaults: command not found
/etc/init.d/mysqld: line 247: @HOSTNAME@: command not found
/etc/init.d/mysqld: line 256: @HOSTNAME@: command not found
经检查mysqld配置文件的内容,发现以下的目录没有定义
basedir=
datadir=
根据安装目录情况修改为以下:
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/var/
修改完成后,可以启动服务,但还是有报错
/etc/init.d/mysqld: line 247: @HOSTNAME@: command not found
/etc/init.d/mysqld: line 256: @HOSTNAME@: command not found
后来在mysql的官方网上发现以下解决方法:
修改以下两行:
mysql.server.sh:247: pid_file=$datadir/mysqlmanager-@HOSTNAME@.pid
mysql.server.sh:256: server_pid_file=$datadir/@HOSTNAME@.pid
修改后:
pid_file=$datadir/mysqlmanager-'@HOSTNAME@'.pidserver_pid_file=$datadir/'@HOSTNAME@'.pid
也就是在给变量@HOSTNAME@ 加上单引号