我有一个在 Amazon Linux AMI 上运行的亚马逊 ec2 实例。我正在尝试/home/ec2-user/data
使用以下配置文件(/etc/my.cnf
)将 mysql 的数据目录移动到第二个卷(安装在)上,但 mysql 无法启动:
[mysqld]
datadir=/home/ec2-user/data/mysql
socket=/home/ec2-user/data/mysql/mysql.sock
log-bin=/var/log/mysql/mariadb-bin
log-bin-index=/var/log/mysql/mariadb-bin.index
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[client]
port=3306
socket=/home/ec2-user/data/mysql/mysql.sock
我在日志文件中收到这些错误消息:
2017-10-12 14:06:33 20082 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2017-10-12 14:06:33 20082 [ERROR] Can't start server : Bind on unix socket: Permission denied
2017-10-12 14:06:33 20082 [ERROR] Do you already have another mysqld server running on socket: /home/ec2-user/data/mysql/mysql.sock ?
2017-10-12 14:06:33 20082 [ERROR] Aborting
当我将配置文件设置回以前的设置(数据文件夹的备份)时,一切正常:
[mysqld]
datadir=/var/lib/mysql.bak
socket=/var/lib/mysql.bak/mysql.sock
log-bin=/var/log/mysql/mariadb-bin
log-bin-index=/var/log/mysql/mariadb-bin.index
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[client]
port=3306
socket=/var/lib/mysql.bak/mysql.sock
这个问题的原因可能是什么?我已经检查了新数据文件夹的权限,但这并没有改变任何东西。