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.
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.
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.
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.
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'
If you not installed MySql.
Ubuntu
sudo apt update
sudo apt-get install mysql-client
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With