Monday, October 17, 2016

How to fix : Cannot login MySQL without sudo command (Ubuntu)

1. Log MySQL with sudo command
sudo mysql -u root

2. Drop current [email protected] account
mysql> DROP USER 'root'@'localhost';

3. Recreate your user *without password
mysql> CREATE USER 'root'@'%' IDENTIFIED BY '';

4. Give all database and table permissions to your root user then flush privileges
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
mysql> FLUSH PRIVILEGES;

Done! Now you can use MySQL without sudo command. I suggested you to restart MySQL services after this work around. bye!

No comments:

Post a Comment