20

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.

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

/usr/local/mysql/bin

And and at unix prompt type:

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

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

$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> -u root -p
    ->

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

I am unable to login to phpMyAdmin. Thanks.

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

The link that in have referenced above. Responses from 2013

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

Community
  • 1
  • 1
iHaveAQuestion
  • 291
  • 2
  • 4
  • 14
  • These are the first sentences of instructions "On Unix, use the following procedure to reset the password for all MySQL root accounts. The instructions assume that you will start the server so that it runs using the Unix login account that you normally use for running the server". Start the server. Which server ? The apache server ? I just open terminal and apache is running anyway that is unless I one apachectl stop. – iHaveAQuestion Mar 14 '14 at 17:36
  • possible duplicate of [can't access mysql from command line mac](http://stackoverflow.com/questions/8195418/cant-access-mysql-from-command-line-mac) – kishanio Aug 15 '15 at 13:23

3 Answers3

49

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

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

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

mysql -u root

otherwise you are using wrong root password.

Ref: Setting the MySQL root user password on OS X

Community
  • 1
  • 1
panther_
  • 502
  • 3
  • 3
  • Thankyou Panther. I had gotten past that problem but today logged on about something else. I am keeping your above posted suggestions. They seem very logical of course :) – iHaveAQuestion Apr 29 '14 at 15:37
  • The above can solve the -13 error from child_process.spawn in node as well. (I had added what I thought was needed in the path... it worked for my login but did not work for node). – MER Oct 28 '20 at 22:56
7

For a Permanent Solution -

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

  2. . ~/.bash_profile

Refer to details at this link.

JNYRanger
  • 6,270
  • 12
  • 46
  • 71
Dan
  • 93
  • 1
  • 5
1

You can permanently add PATH to your ~/.bash_profile by following. This will save you to run export command every time you reopen the console or terminal.

  1. Open ~/.bash_profile file using

    sudo nano ~/.bash_profile 
    
  2. Add following line there

    export PATH=$PATH:/usr/local/mysql/bin/
    
  3. Save and exit the file and refresh ~/.bash_profile file

    source ~/.bash_profile
    
  4. Enjoy

user3253756
  • 331
  • 3
  • 9