我尝试重新安装 mysql-server,但在安装过程中收到某种警告。它已安装但无法正常工作。
Setting up mysql-client-core-5.7 (5.7.23-0ubuntu0.18.04.1) ...
Setting up mysql-server-core-5.7 (5.7.23-0ubuntu0.18.04.1) ...
Setting up mysql-client-5.7 (5.7.23-0ubuntu0.18.04.1) ...
Setting up mysql-server-5.7 (5.7.23-0ubuntu0.18.04.1) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide
/etc/mysql/my.cnf (my.cnf) in auto mode
Renaming removed key_buffer and myisam-recover options (if present)
Cannot stat file /proc/1927/fd/4: Permission denied
Cannot stat file /proc/1927/fd/5: Permission denied
Cannot stat file /proc/1927/fd/6: Permission denied
Cannot stat file /proc/1927/fd/25: Permission denied
Cannot stat file /proc/1927/fd/35: Permission denied
Cannot stat file /proc/1927/fd/36: Permission denied
Cannot stat file /proc/1927/fd/37: Permission denied
Cannot stat file /proc/1927/fd/38: Permission denied
Cannot stat file /proc/1927/fd/39: Permission denied
Cannot stat file /proc/1927/fd/40: Permission denied
Cannot stat file /proc/1927/fd/41: Permission denied
Cannot stat file /proc/1927/fd/101: Permission denied
Cannot stat file /proc/1927/fd/102: Permission denied
Cannot stat file /proc/1927/fd/1023: Permission denied
Cannot stat file /proc/2091/fd/5: Permission denied
Cannot stat file /proc/2091/fd/6: Permission denied
Cannot stat file /proc/2091/fd/7: Permission denied
Cannot stat file /proc/2091/fd/8: Permission denied
Cannot stat file /proc/2091/fd/9: Permission denied
Cannot stat file /proc/2091/fd/10: Permission denied
Cannot stat file /proc/2091/fd/11: Permission denied
Cannot stat file /proc/2091/fd/12: Permission denied
Cannot stat file /proc/2091/fd/13: Permission denied
Cannot stat file /proc/2091/fd/14: Permission denied
Cannot stat file /proc/2176/fd/3: Permission denied
Cannot stat file /proc/2316/fd/5: Permission denied
Cannot stat file /proc/2316/fd/6: Permission denied
Cannot stat file /proc/2316/fd/7: Permission denied
Cannot stat file /proc/2316/fd/8: Permission denied
Cannot stat file /proc/2316/fd/9: Permission denied
Cannot stat file /proc/2316/fd/10: Permission denied
Cannot stat file /proc/2316/fd/11: Permission denied
Cannot stat file /proc/2316/fd/12: Permission denied
Cannot stat file /proc/2316/fd/13: Permission denied
Cannot stat file /proc/2316/fd/14: Permission denied
Cannot stat file /proc/2316/fd/18: Permission denied
Cannot stat file /proc/2316/fd/19: Permission denied
Cannot stat file /proc/2316/fd/38: Permission denied
Cannot stat file /proc/2334/fd/4: Permission denied
Cannot stat file /proc/2334/fd/5: Permission denied
Cannot stat file /proc/2334/fd/6: Permission denied
Cannot stat file /proc/2334/fd/25: Permission denied
Cannot stat file /proc/2334/fd/35: Permission denied
Cannot stat file /proc/2334/fd/36: Permission denied
Cannot stat file /proc/2334/fd/37: Permission denied
Cannot stat file /proc/2334/fd/38: Permission denied
Cannot stat file /proc/2334/fd/39: Permission denied
Cannot stat file /proc/2334/fd/40: Permission denied
Cannot stat file /proc/2334/fd/41: Permission denied
Cannot stat file /proc/2334/fd/101: Permission denied
Cannot stat file /proc/2334/fd/102: Permission denied
Cannot stat file /proc/2334/fd/1023: Permission denied
Created symlink /etc/systemd/system/multi-
user.target.wants/mysql.service → /lib/systemd/system/mysql.service.
Setting up mysql-server (5.7.23-0ubuntu0.18.04.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for systemd (237-3ubuntu10.3) ...
Processing triggers for ureadahead (0.100.0-20) ...
答案1
我在尝试重新安装 mysql 时也遇到过类似的问题。但就我而言,我只收到一条消息:
Cannot stat file /proc/5346/fd/1023: Permission denied
使用dpkg --list | grep mysql
我发现我需要删除哪些包:
$ sudo apt purge mysql-client-8.0 mysql-client-core-8.0 mysql-common mysql-server-8.0 mysql-server-core-8.0
但是它询问我是否要删除以下依赖包:
The following packages will be REMOVED:
budgie-desktop* budgie-desktop-environment* colord* glewlwyd* gnome-control-center* hpijs-ppds* hplip* hplip-gui* libdbd-mysql-perl*
libhoel1.4* libhpmud0* libmailutils6* libmysqlclient-dev* libmysqlclient21* libsane* libsane-dev* libsane-hpaio* libsnmp-dev*
libsnmp35* mailutils* mysql-client-8.0* mysql-client-core-8.0* mysql-common* mysql-server-8.0* mysql-server-core-8.0*
printer-driver-hpcups* printer-driver-hpijs* sane-utils* simple-scan* snmp* sysbench* xsane*
尝试执行相同的操作并将这些包字符串保存在驱动器上的某个位置。例如,我将它们保存在~/packages
文件中,删除了星号和换行符。
$ cat packages
budgie-desktop budgie-desktop-environment colord glewlwyd gnome-control-center hpijs-ppds hplip hplip-gui libdbd-mysql-perl libhoel1.4 libhpmud0 libmailutils6 libmysqlclient-dev libmysqlclient21 libsane libsane-dev libsane-hpaio libsnmp-dev libsnmp35 mailutils mysql-common printer-driver-hpcups printer-driver-hpijs sane-utils simple-scan snmp sysbench xsane
所以我意识到了这个问题。它要求删除一些桌面环境包。这意味着,如果你清除或删除 mysql 包,它的一些文件仍在使用中,因此无法删除它们。
要正确地重新安装 mysql 包:
停止您的显示管理器(可能是 gdm3、lightdm、xdm 等):
$ sudo systemctl stop gdm3
按以下方式切换到某个终端:Ctrl++AltF3
登录
清除
mysql-client-8.0 mysql-client-core-8.0 mysql-common mysql-server-8.0 mysql-server-core-8.0
重启
切换到第三个终端,登录并停止显示管理器
安装所有已删除的软件包:
$ sudo apt install $(cat ~/packages)
启动显示管理器
$ sudo systemctl start gdm3
结果,我重新安装了 mysql 包,没有出现那个错误。
我还将其他 mysql 服务器安装到 3306 端口上的非标准文件夹中,因此我需要将新安装的 mysql 服务器监听端口更改为/etc/mysql/mysql.conf.d/mysqld.cnf
文件中的其他内容。
答案2
如果你在 windows 子系统 ubuntu18 上安装 mysql-server,那么你可以直接去安装 ubuntu1604。我试了很多办法,但只有在 ubuntu1604 上才能正常 apt-get 安装 mysql-server。同时,如果你之前在 windows 10 上安装过 mysql 软件,你应该先卸载 win10 mysql。(我不知道原因)
完成所有这些后,尝试以下命令
sudo apt purge mysql*
sudo rm -rf /var/lib/mysql
sudo rm -rf /etc/mysql
sudo apt autoremove
sudo apt install mysql-server