Mysqldump command not found

2019-03-24 16:36发布

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?

7条回答
该账号已被封号
2楼-- · 2019-03-24 16:58

For mac users, look into /usr/local/, this is most likely where mysql is installed. There may be two installations. I chose the one without the version number in the name.

You need to add the path of your mysql installation to your bash profile by adding export PATH=$PATH:/usr/local/mysql/bin to ~/.bash_profile. Can try running PATH=$PATH:/usr/local/mysql/bin if adding export to ~/.bash_profile doesn't work.

查看更多
时光不老,我们不散
3楼-- · 2019-03-24 17:01

You are actually trying using git bash, please try CMD xampp/mysql/bin then run

mysqldump -u root -p DbName> name_to_downlaod.sql

查看更多
兄弟一词,经得起流年.
4楼-- · 2019-03-24 17:03

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
查看更多
smile是对你的礼貌
5楼-- · 2019-03-24 17:04

You probably don't have the MySQL /bin folder on your PATH. Change to your mysql /bin folder and try the command again.

查看更多
SAY GOODBYE
6楼-- · 2019-03-24 17:05

For OS X and MAMP (localhost) open Terminal and run

sudo nano ~/.bash_profile

Add the following code (make sure to change the -uroot -proot by the username and password you have for mysql):

alias mysqldump='/Applications/MAMP/Library/bin/mysqldump --host=localhost -uroot -proot'

Once added, Press Ctrl + O to save then Ctrl X to leave the editor, now run on the terminal

mysqldump dbname > dump_name.sql

That worked perfectly for me.

查看更多
小情绪 Triste *
7楼-- · 2019-03-24 17:07

My solution: (On windows)
1, Right click to your computer ==> Properties ==> Advanced system settings ==> on tabs "Advanced" click Environments Variables ==> on System variables find "Path" and click "Edit".
2, Finally, you copy your bin folder of your mysql to that.
Ex: D:\LEARN\wamp64\bin\mysql\mysql5.7.14\bin
3, Restart cmd and try your command again.
Nice..

查看更多
登录 后发表回答