Mysqldump command not found

匿名 (未验证) 提交于 2019-12-03 03:04:01

问题:

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?

回答1:

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.)



回答2:

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



回答3:

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 


回答4:

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.



回答5:

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..



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!