![在 Ubuntu 16.04 上卸载 MySQL 5.7 后重新安装时出现问题](https://linux22.com/image/1060481/%E5%9C%A8%20Ubuntu%2016.04%20%E4%B8%8A%E5%8D%B8%E8%BD%BD%20MySQL%205.7%20%E5%90%8E%E9%87%8D%E6%96%B0%E5%AE%89%E8%A3%85%E6%97%B6%E5%87%BA%E7%8E%B0%E9%97%AE%E9%A2%98.png)
我在 Ubuntu 16.04 上安装了 LAMP,运行顺畅。由于我忘记了 PhpMyAdmin 用户名,我尝试删除现有的所有 MySQL 文件,然后在重新安装 MySQL 5.7 时显示以下错误。我现在该怎么办?请帮忙。
tridip@tridip-HP-ProBook-440-G2:~$ sudo apt-get install mysql-server
[sudo] password for tridip:
Reading package lists... Done
Building dependency tree
Reading state information... Done
mysql-server is already the newest version (5.7.18-1ubuntu16.04).
The following packages were automatically installed and are no longer required:
libdbd-mysql-perl libdbi-perl libmysqlclient20 libterm-readkey-perl
mariadb-common
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up mysql-community-server (5.7.18-1ubuntu16.04) ...
my_print_defaults: Can't read dir of '/etc/mysql/conf.d/' (Errcode: 2 - No such file or directory)
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
my_print_defaults: Can't read dir of '/etc/mysql/conf.d/' (Errcode: 2 - No such file or directory)
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
my_print_defaults: Can't read dir of '/etc/mysql/conf.d/' (Errcode: 2 - No such file or directory)
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
my_print_defaults: Can't read dir of '/etc/mysql/conf.d/' (Errcode: 2 - No such file or directory)
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
mysqld: Can't read dir of '/etc/mysql/conf.d/' (Errcode: 2 - No such file or directory)
mysqld: [ERROR] Fatal error in defaults handling. Program aborted!
dpkg: error processing package mysql-community-server (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-community-server (= 5.7.18-1ubuntu16.04); however:
Package mysql-community-server is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
mysql-community-server
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
答案1
我在使用新的 Ubuntu 18.04 时遇到了同样的问题。以下是我解决问题的方法:
sudo mkdir /etc/mysql/conf.d
然后我按照错误消息的建议进行操作:
sudo apt autoremove
此时 MySQL 服务器可能正在运行,但是为了确保万无一失,我还是希望重新启动。因此,我执行了:
sudo apt remove mysql-server
sudo apt install mysql-server
现在它应该可以工作了!:)
答案2
我建议你最好遵循它对你说的话。
sudo apt autoremove
此外还有这个目录:
/etc/mysql/conf.d/
不存在 - 您可以手动创建它,但我不建议这样做,因为我不知道您最终可能会创建多少个目录和子目录。
最好重新安装 LAMP