自动 MySQL 安装中没有用户

自动 MySQL 安装中没有用户

我正在尝试使用以下命令自动安装 MySQL:

echo 'mysql-server-5.5 mysql-server/root_password password some_password' | /usr/bin/debconf-set-selections
echo 'mysql-server-5.5 mysql-server/root_password_again password some_password' | /usr/bin/debconf-set-selections
export DEBIAN_FRONTEND=noninteractive
/usr/bin/apt-get install mysql-server-5.5 -y

但是,在安装过程中,我收到此错误:

Setting up mysql-server-5.5 (5.5.53-0+deb8u1) ...
161206 14:10:54 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
161206 14:10:54 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
161206 14:10:54 [Note] /usr/sbin/mysqld (mysqld 5.5.53-0+deb8u1) starting as process 12755 ...
Configuring mysql-server-5.5
----------------------------

Unable to set password for the MySQL "root" user

An error occurred while setting the password for the MySQL administrative 
user. This may have happened because the account already has a password, or 
because of a communication problem with the MySQL server.

You should check the account's password after the package installation.

Please read the /usr/share/doc/mysql-server-5.5/README.Debian file for more information.

Job for mysql.service failed. See 'systemctl status mysql.service' and 'journalctl -xn' for details.
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing package mysql-server-5.5 (--configure):
 subprocess installed post-installation script returned error exit status 1

这是在一台新服务器上,所以我不太清楚为什么会发生这种情况,因为这个帖子会表明过去失败的安装存在问题。

如果我使用 登录--skip-grant-tables,然后FLUSH PRIVILEGES,创建一个新用户,重新启动 mysql,该用户可以登录。然后发生了最奇怪的事情(我认为)。使用新用户登录,使用 mysql 数据库,并选择所有用户,会拉出一行,其中没有 root 用户和一个用户(我刚刚创建的)。

该脚本必须自动部署,所以我不能在每台服务器上手动创建用户。

相关内容