15

How to import and export MySQL dump file on a Mac?

Like on Windows, I use this code:

mysqldump -u root -p --databases DBname>d:\ FILENAME.sql

But it does not work on Mac terminal. It produces the following error:

-bash: mysqldump: command not found
informatik01
  • 16,038
  • 10
  • 74
  • 104
Neeraj Sharma
  • 297
  • 1
  • 4
  • 16

2 Answers2

27

The location where mysqldump is installed need to be declared in your $PATH.

If you don't know how to edit your $PATH on macOS, you can refer to this question.

For example, if your mysqldump binary is located in /usr/local/mysql/bin, you can edit your $PATH to:

export PATH=$PATH:/usr/local/mysql/bin

With this modification, you won't have to provide the full path to the mysqldump binary every time and will be able to use your command:

$ mysqldump -u root -p --databases DBname>d:\ FILENAME.sql
Community
  • 1
  • 1
HiDeoo
  • 10,353
  • 8
  • 47
  • 47
6

i forget to give path to it the query is

/usr/local/mysql/bin/mysqldump -uroot -p friendstree > friendstree.sql

it worked

Neeraj Sharma
  • 297
  • 1
  • 4
  • 16