Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysqldump command not found

Tags:

I want to export my database and i am using this code:

mysqldump -p -u markazo_b markazo_b > /tmp/file.sql 

But SSH show this error:

-bash: mysqldump: command not found

How i fix this problem?

like image 900
okancelik Avatar asked Jun 21 '14 14:06

okancelik


People also ask

Why Mysqldump is not working?

If mysqldump is not identified by the cmd prompt that means it cannot recognize where the mysqldump.exe is located. You need to add path of the directory where the exe is located in the PATH variable under environment variables. After doing that your command will start working in the cmd prompt.

Where can I find Mysqldump?

The mysqldump tool is located in the root/bin directory of the MySQL installation directory.

What is Mysqldump command?

It dumps one or more MySQL databases for backup or transfer to another SQL server. The mysqldump command can also generate output in CSV, other delimited text, or XML format.

How do I run Mysqldump on Windows?

To dump/export a MySQL database, execute the following command in the Windows command prompt: mysqldump -u username -p dbname > filename. sql . After entering that command you will be prompted for your password.


2 Answers

After reading your conversation, I found the solution (for me, at least). It was a permissions issue.

Issuing which mysqldump in the terminal shows /usr/bin/mysqldump.

When I then issue cd /usr/bin/ and afterward mysqldump I receive the same indications you were seeing: mysqldump: command not found.

Inside /usr/bin I then issued sudo mysqldump and received:

Usage: mysqldump [OPTIONS] database [tables] OR     mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...] OR     mysqldump [OPTIONS] --all-databases [OPTIONS] For more options, use mysqldump --help 

Try that and see if it helps.

Edit: too long, didn't read: sudo mysqldump may work. (May be a permissions issue.)

like image 195
Tass Avatar answered Sep 18 '22 18:09

Tass


The solution I found is adding MySql's installation directory to PATH

Steps:

  1. Find where MySql is installed
  2. Add the bin directory of MySql installation to PATH

(In the terminal),

locate mysqldump  export PATH=$PATH:MY_SQL_INSTALLATION_DIRECTORY/bin 

MY_SQL_INSTALLATION_DIRECTORY is the directory you found by locate mysqldump: Example

export PATH=$PATH:/usr/local/mysql-5.6.23-osx10.8-x86_64/bin 
like image 39
biniam Avatar answered Sep 19 '22 18:09

biniam