1

I installed LAMP on my Ubuntu 16.04 and it was running smooth. As I forgot my PhpMyAdmin username I tried to remove the existing all MySQL files then while reinstalling MySQL 5.7 it shows the following error. What should I do now? Please help.

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)

2 Answers 2

2

I had the same problem with the new Ubuntu 18.04. Here's what I did to solve this:

sudo mkdir /etc/mysql/conf.d

then I did what the error message suggested:

sudo apt autoremove

At this point MySQL server is probably working, but I prefer start again, just to be sure. So, I did:

sudo apt remove mysql-server
sudo apt install mysql-server

It should work by now! :)

1
  • It's rarely a good idea to remove a program and then install it again, and if you aren't going to purge it to remove config files, there's really no benefit over the much safer sudo apt install --reinstall <package> which avoids dependency calculations that could result in more packages getting removed that you bargained for. Simple package-management operations are reversible, but for packages with many dependencies, they often are not
    – Zanna
    May 18, 2018 at 16:01
1

I will suggest better to follow what it is saying to you.

sudo apt autoremove

Moreover this directory:

/etc/mysql/conf.d/

is not present - you can manually create it but I won't recommend as I don't know how many directories and subdirectories you might end up creating.

Best to re-install LAMP all over again

1
  • But the directory is present
    – Allen King
    Dec 7, 2020 at 19:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .