Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL password issues (mac OS X Lion) [closed]

Tags:

I am trying to set the root password for MySQL in the terminal in Mac OS X Lion, and I am having issues. Every time I use the line:

/usr/local/mysql/bin/mysqladmin -u root password ******  (where ****** is the password I want to set) 

I receive the error:

/usr/local/mysql/bin/mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: NO)' 

I have not set a password previously, so I do not know why I am receiving this error.

like image 869
user1072337 Avatar asked Dec 16 '11 22:12

user1072337


People also ask

Why mysql is not working in Mac?

The reason behind the MySQL Workbench client not working can be many. It can be because your macOS version is not compatible with the version of the Workbench that you downloaded, or maybe because the version of Python installed on your macOS is not compatible with the version of Workbench you have downloaded.

What is the default root password for Mac?

By default the root account is supposed to be disabled, but by default the root user also has a blank password. For some reason, the system is first enabling the root user (which is supposed to be disabled by default) then doing a password check. With no set password, submitting a blank password matches and you're in.


1 Answers

Here is the procedure to reset password of root user.

1) Stop mysql (Kill mysql process or run following command)

sudo /usr/local/mysql/support-files/mysql.server stop 

2) Start it in safe mode

sudo mysqld_safe --skip-grant-tables 

3) Open another terminal and run the following command (Keep last terminal open)

mysql -u root 

4) Run the following command with suitable new password on the mysql console

For MySQL 5.7+:

mysql > UPDATE mysql.user SET authentication_string=PASSWORD('password') WHERE User='root'; 

For earlier versions:

mysql > UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root'; 

5) mysql > FLUSH PRIVILEGES;

6) Quit from both terminals and open new terminal and connect to mysql with root user and new password

mysql -uroot -p 
like image 190
minhas23 Avatar answered Sep 25 '22 15:09

minhas23