Root account cannot connect

This is actually a good restriction. As a general thumb of rule, you should not use the root account for the applications.

Although not recommended, you can allow root user to connect via a password (and not auth_socket) by using the command:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'rootpassword';

A better solution would be to create a new user, set the privileges accordingly and use that account from your application.

First you should connect to the database (type the password accordingly):

sudo mysql -u root -p

Then create the user:

CREATE USER 'bob'@'localhost' IDENTIFIED BY 'bobpasswd';
GRANT ALL PRIVILEGES ON * . * TO 'bob'@'localhost';

Then use the new account in your application.


Leave a Reply