【发布时间】:2019-11-17 23:43:49
【问题描述】:
我正在尝试在没有任何提示的情况下在 Ubuntu(即 Linux 的 Windows 子系统)上安装 MySQL 8。
我有以下脚本:
apt-key add --keyserver pgp.mit.edu --recv-keys 5072E1F5
echo 'deb http://repo.mysql.com/apt/ubuntu/ bionic mysql-8.0' > /etc/apt/sources.list.d/mysql.list
apt-get update --yes
apt-get install --yes debconf-utils
echo 'mysql-community-server mysql-community-server/root-pass password' | sudo debconf-set-selections
echo 'mysql-community-server mysql-community-server/re-root-pass password' | sudo debconf-set-selections
apt-get install --yes mysql-community-server
(部分构造感谢this question 中的答案)
它似乎工作正常,除了它提示我选择身份验证方法...我想选择 mysql_native_password 并且这样做而不被交互式提示。
我猜解决方案是另一个 debconf-set-selections 设置,但是......除了询问这种情况下它是什么......在某处是否有所有可能选项的参考?
还有一个问题是 apt-get 说为服务创建了符号链接,但没有创建服务......但这并不是真正的阻碍,因为我只是将 WSL 用作测试场对于一个实际的 Ubuntu 服务器,我认为这会起作用......希望。
EDIT1:别管原来的问题...我设法找到了答案here 这导致偶然发现this dockerfile
所以我最终添加了
echo 'mysql-community-server mysql-server/default-auth-override select Use Legacy Authentication Method (Retain MySQL 5.x Compatibility)' | sudo debconf-set-selections
是我需要的线...
但是,另一个可能是 WSL 特定的问题仍然存在……也就是说,没有创建 MySQL 服务。我应该注意,当我在 WSL 之外安装 MySQL 时,服务器已关闭,特别是为了让 WSL 可以运行。
我在安装时得到以下输出,接近尾声:
Setting up mysql-community-server (8.0.16-2ubuntu18.04) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
dpkg: error processing package mysql-community-server (--configure):
installed mysql-community-server package post-installation script subprocess returned error exit status 1
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Errors were encountered while processing:
mysql-community-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
我能找到的唯一与之相关的是完全重新安装的建议,但即使重新安装 WSL 实例也不能解决这个问题。
EDIT2:添加
apt-get dist-upgrade --yes --allow-remove-essential --allow-change-held-packages
修复了上面的错误,尽管没有任何错误,服务仍然没有创建。
【问题讨论】:
标签: mysql bash ubuntu windows-subsystem-for-linux