MySQL MySQL命令行'-bash命令未找到'

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22391778/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 20:13:46  来源:igfitidea点击:

MySQL command line '-bash command not found'

mysqlmacosbashphpmyadmin

提问by iHaveAQuestion

The following link at the end of the post was helpful but can someone clarify this. There are 2 answers that are in complete conflict so I am asking about it.

帖子末尾的以下链接很有帮助,但有人可以澄清这一点。有 2 个答案完全冲突,所以我在问。

One person responds that you should get to the MySQL command line like this Navigate to the directory

一个人回应说你应该像这样进入 MySQL 命令行 Navigate to the directory

/usr/local/mysql/bin

And and at unix prompt type:

并在 unix 提示符下键入:

Macbookpro$./mysql

Then type the following to reset the password.

然后键入以下内容以重置密码。

mysql -u root -p

But then another person says:

但后来又有人说:

"No, you should run mysql -u root -p in bash, not at the MySQL command-line. If you are in mysql, you can exit by typing exit."

“不,你应该在 bash 中运行 mysql -u root -p,而不是在 MySQL 命令行中。如果你在 mysql 中,你可以通过输入 exit 退出。”

Neither of these work for me. First method From the bash prompt:

这些都不适合我。第一种方法从 bash 提示符:

$macbookpro mysql -u root -p
Enter password:  xxxx
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Second method from mysql> prompt

来自 mysql> 提示符的第二种方法

mysql> -u root -p
    ->

I also often get this error: -bash command not found

我也经常收到这个错误:-bash command not found

I am unable to login to phpMyAdmin. Thanks.

我无法登录到 phpMyAdmin。谢谢。

My problem is that I am getting this error message when trying to login to phpMyAdmin. "Login without a password is forbidden by configuration"

我的问题是我在尝试登录 phpMyAdmin 时收到此错误消息。“配置禁止无密码登录”

The link that in have referenced above. Responses from 2013

上面引用的链接。2013 年的回应

ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'db'

错误 1044 (42000):用户 ''@'localhost' 对数据库 'db' 的访问被拒绝

回答by panther_

To use command i.e. $mysql on macbook terminal you need to export path using:

要在 macbook 终端上使用命令即 $mysql,您需要使用以下命令导出路径:

export PATH=$PATH:/usr/local/mysql/bin/

considering default installation use following command to get mysql prompt as root user:

考虑默认安装,使用以下命令以 root 用户身份获取 mysql 提示:

mysql -u root

otherwise you are using wrong root password.

否则你使用了错误的 root 密码。

Ref: Setting the MySQL root user password on OS X

参考:在 OS X 上设置 MySQL root 用户密码

回答by Dan

For a Permanent Solution -

对于永久解决方案 -

  1. echo 'export PATH=/usr/local/mysql/bin:$PATH' >> ~/.bash_profile

  2. . ~/.bash_profile

  1. echo 'export PATH=/usr/local/mysql/bin:$PATH' >> ~/.bash_profile

  2. . ~/.bash_profile

Refer to details at this link.

请参阅此链接中的详细信息。