Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysqldump isn't working: "command not found"

I have to export a database from the command line. I tried using this command:

mysqldump -u root -p db_name > backup.sql

But it returns this error:

-bash: mysqldump: command not found

After this, I also tried with

sudo mysqldump

but the error is the same.

I'm at the beginning and I'm not very good at it at the moment. If I have to work on directory, please be clear because I'm not confident with the terminal.

like image 337
FranzGoogle Avatar asked Apr 27 '16 14:04

FranzGoogle


People also ask

Why mysqldump is not identified by the CMD prompt?

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.

How do I find the mysqldump?

Show activity on this post. If the mysqldump can not be identified by your CMD prompt (I believe you are using Windows), then you first have to go to the bin folder where this command can be found. In my case, the path is "C:\wamp\bin\mysql\mysql5.5.24\bin", it would be more or less the same path for you.

Where can I find the mysqldump executable in El Capitan?

If you have the latest mysql installation in El Capitan, the mysqldump executable should be in the /usr/local/mysql/bin directory. In order to use it, you can either run /usr/local/mysql/bin/mysqldump directly, create a symlink, or add the whole bin directory to your path, so you can use any of the executable files without typing the full path.

Is mysqldump available in Raspbian?

Except this, no errors are returned and the zip is created with the .sql file included but with no text. Thanks in advance :) mysqldump is part of mysql / mariadb client packages. For Raspbian Jessie install package 'mysql-client', for Stretch you need 'mariadb-client'


2 Answers

If you not installed MySql.
Ubuntu

sudo apt update
sudo apt-get install mysql-client
like image 88
Kairat Koibagarov Avatar answered Sep 21 '22 19:09

Kairat Koibagarov


If you have the latest mysql installation in El Capitan, the mysqldump executable should be in the /usr/local/mysql/bin directory. In order to use it, you can either run /usr/local/mysql/bin/mysqldump directly, create a symlink, or add the whole bin directory to your path, so you can use any of the executable files without typing the full path.

As suggested below, you can easily make a symlink in your /usr/bin directory, which should already be in your path, by running this command: ln -s /usr/bin/mysqldump /usr/local/mysql/bin/mysqldump

That command should create a link called mysqldump in your /usr/bin directory, which will redirect to the full path of the mysqldump program.

If you would rather add the entire mysql library of tools, all at once, you can follow this guide: https://coolestguidesontheplanet.com/add-shell-path-osx/ and learn how to add new directories to your path.

like image 42
Daniel Avatar answered Sep 17 '22 19:09

Daniel