Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL command line '-bash command not found'

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

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

Navigate to the directory

/usr/local/mysql/bin

And at a Unix prompt, type:

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

Neither of these work for me.

First method. From the Bash prompt:

mysql -u root -p

Enter password:  xxxx
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Second method from the mysql> prompt:

mysql> -u root -p
    ->

I also often get this error:

-bash command not found

I am unable to log in to phpMyAdmin.

My problem is that I am getting this error message when trying to log in to phpMyAdmin:

Login without a password is forbidden by configuration

The link that I have is referenced above. Responses from 2013:

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

like image 666
iHaveAQuestion Avatar asked Mar 13 '14 21:03

iHaveAQuestion


People also ask

How do I fix bash command not found?

Install a package Sometimes when you try to use a command and Bash displays the "Command not found" error, it might be because the program is not installed on your system. Correct this by installing a software package containing the command.

How do I run MySQL from command line?

Launch the MySQL Command-Line Client. To launch the client, enter the following command in a Command Prompt window: mysql -u root -p . The -p option is needed only if a root password is defined for MySQL. Enter the password when prompted.


2 Answers

To use the command, i.e., mysql on a MacBook terminal, you need to export the path using:

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

Considering the default installation, use the following command to get the mysql prompt as the root user:

mysql -u root

Otherwise you are using the wrong root password.

Reference: Setting the MySQL root user password on OS X

like image 56
panther_ Avatar answered Oct 02 '22 10:10

panther_


For a permanent solution -

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

  2. . ~/.bash_profile

Refer to details at this link.

like image 7
Dan Avatar answered Oct 02 '22 09:10

Dan