mysqld: Can't read dir of '/etc/mysql/conf.d/' (OS errno 2 - No such file or directory)

9,158

Open a terminal window and create the directory mentioned in the error message using mkdir with p option.

sudo mkdir -p /etc/mysql/conf.d/

p option will create parent directories as well, in case they don't exist.

Create a new file mysql.cnf in the above said directory and add [mysql]. That can be done using tee as well.

echo "[mysql]" | sudo tee /etc/mysql/conf.d/mysql.cnf

Finally try re-configuring packages using

sudo dpkg --configure -a

Note: A special thanks to Orphans for confirming the applicability of the answer in comments.

Share:
9,158
Tomáš Sidorják
Author by

Tomáš Sidorják

Updated on September 18, 2022

Comments

  • Tomáš Sidorják
    Tomáš Sidorják over 1 year

    I am trying to install mysql-server by using sudo apt-get install mysql-server but apt says this:

    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-server-8.0
     mysql-server
    E: Sub-process /usr/bin/dpkg returned an error code (1)`
    

    after doing configure on dpkg it says

    # sudo dpkg --configure -a
    Setting up mysql-server-8.0 (8.0.20-0ubuntu0.20.04.1) ...
    Renaming removed key_buffer and myisam-recover options (if present)
    ERROR: Unable to start MySQL server:
    mysqld: Can't read dir of '/etc/mysql/conf.d/' (OS errno 2 - No such file or directory)
    mysqld: [ERROR] Fatal error in defaults handling. Program aborted!
    Please take a look at https://wiki.debian.org/Teams/MySQL/FAQ for tips on fixing common upgrade issues.
    Once the problem is resolved, run apt-get --fix-broken install to retry.
    dpkg: error processing package mysql-server-8.0 (--configure):
     installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
    dpkg: dependency problems prevent configuration of mysql-server:
     mysql-server depends on mysql-server-8.0; however:
      Package mysql-server-8.0 is not configured yet.
    
    dpkg: error processing package mysql-server (--configure):
     dependency problems - leaving unconfigured
    Errors were encountered while processing:
     mysql-server-8.0
     mysql-server
    
    • thorstorm
      thorstorm almost 4 years
      Try running sudo apt update and check for any errors and what it recommends.
    • Tomáš Sidorják
      Tomáš Sidorják almost 4 years
      update is succesful but installation have same error
    • thorstorm
      thorstorm almost 4 years
      Have you added ppas and other sources?
    • Tomáš Sidorják
      Tomáš Sidorják almost 4 years
      no, everything is still same as before
    • Kulfy
      Kulfy almost 4 years
      Are you still facing the issue? If yes, open a terminal and run sudo mkdir -p /etc/mysql/conf.d/, then sudo nano mysql.cnf and paste [mysql] and save. Again run sudo nano mysqldump.cnf and paste this. Save and retry sudo dpkg --configure -a. If you still get errors ping me using @kulfy in comments otherwise I may miss your comment. Thanks.
    • Orphans
      Orphans about 3 years
      @Kulfy The paste that you linked to does not exist.
    • Kulfy
      Kulfy about 3 years
      @Orphans Uh.. Oh!! Let me check if I can have contents of that file again. Also, please note that you need to create mysql.cnf in /etc/mysql/conf.d/ (I missed cding in the comment). Can you please try sudo dpkg --configure -a only without creating mysqldump.conf (i.e., only with mysql.cnf) since I had no way to confirm that really worked?
    • Orphans
      Orphans about 3 years
      @Kulfy Yeah I did try that, and it worked without the mysqldump.conf actually :) Thanks! You are a lifesaver
    • Kulfy
      Kulfy about 3 years
      @Orphans Excellent!!! I'll post an answer for future visitors. (I can see a deleted answer posted by a new user who was also not able to find the paste :-()
  • Marc Vanhoomissen
    Marc Vanhoomissen over 3 years
    MySQL was not started, as the output clearly say: ERROR: Unable to start MySQL server: mysqld: Can't read dir of '/etc/mysql/conf.d/' (OS errno 2 - No such file or directory) Why do you think any of your proposal would solve the problem?