Unable To Access Mysql With Root and No Password After New Install On Ubuntu

This bit me in the rear end again today. Had to reinstall mysql-server-5.7 for other reasons.

You just installed mysql-server locally for your development environment on a recent version of Ubuntu (I have 17.10 artful installed). You did it with a blank password for root user. You type mysql -u root and you see Access denied for user 'root'@'localhost'.

wat

Issue: Because you chose to not have a password for the root user, the auth_plugin for my MySQL defaulted to auth_socket. That means if you type sudo mysql -u root you will get in. If you don’t, then this is NOT the fix for you.

Solution: Change the auth_plugin to mysql_native_password so that you can use the root user in the database.

$ sudo mysql -u root

mysql> USE mysql;
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> exit;

$ sudo systemctl restart mysql
$ sudo systemctl status mysql

NB ALWAYS set a password for mysql-server in staging/production.

Cheers.

Jason Meridth

jmeridth

My name is Jason Meridth. I am a continuously learning senior software developer/team lead/development manager trying to not let best be the enemy of better. I reserve the right to change my mind upon obtaining more information. I am also the owner and principal software consultant at Meridth, LLC. If you have any software, hardward, networking, process, etc needs please don't hesitate to reach out to me.

Raspberry Pi Kubernetes Cluster - Part 2

Howdy again.Alright, my 8 port switch showed up so I was able to connect my raspberry 3B+ boards to my home network. I plugged it in wit...… Continue reading

Raspberry Pi Kubernetes Cluster - Part 1

Published on April 07, 2018

SSH - Too Many Authentication Failures

Published on March 28, 2018