9

I'm trying to import a database locally using wp db import databasename.sql but I get the following error: env: mysql: No such file or directory. Can anyone tell me how to resolve this?

user2753924
  • 465
  • 1
  • 5
  • 15

3 Answers3

15

I resolved this by changing my $PATH, run this in command or update your .bash_profile:

export PATH=$PATH:/usr/local/mysql/bin
lakewood
  • 607
  • 1
  • 5
  • 21
  • 1
    Just did this and restarted the terminal on MacOs Sierra. Did not work for me. – rhand Jan 31 '18 at 06:59
  • 1
    Worked on Mac OS 10.15.7. only after editing `/etc/paths` and adding `/usr/local/mysql/bin` on a new line, then saving and restarting the Terminal. Now I can do things like 'wp db check'. – Oleg Sep 30 '21 at 22:16
13

The above didn't help me. I fixed it by adding this to my .bash_profile:

export PATH=$PATH:/Applications/MAMP/Library/bin/
5tormTrooper
  • 893
  • 7
  • 21
  • 2
    The difference between your command here and my command above is that you are running MAMP - which is why my vanilla mysql $PATH would not have worked in your case. – lakewood May 14 '18 at 19:20
1

For anyone running Desktop Server, which uses XAMPP, your command that needs to be added to .bash_profile with the following command is:

export PATH=$PATH:/Applications/XAMPP/xamppfiles/bin

Once you add that, you should be able to use wp db import (and not needing to use the wp-cli portal the Desktop Server provides; which wasn't working consistently for me).