Mysql user access denied message for a new ubuntu user
Hi all,
I followed linode ubuntu setup guide, I have now 2 users root and 2nduser with sudo. So I created a new mysql user also, lets call it mysqluser
The problem is when I go to terminal using 2nduser@localhost and then type sudo mysql -u mysqluser -p
It give me access denied to mysqluser@localhost message
But if I type sudo mysql -u root, then it gives me access.
Also, when logged in as root in the terminal i.e root@localhost , then mysql -u mysqluser -p works.
I can connect my PHP to mysql using the same mysql user but it gives me error in terminal.
Any help would be appreaciated.
Thanks
1 Reply
You may need to change to a root shell using sudo su -
before entering your credentials with mysql -u mysqluser -p
. This StackOverflow post has a helpful overview, but essentially newer versions of MySQL require the use of a root shell. Since you mentioned that when you're logged in as root, you can log in as mysqluser
without difficulty, this is likely the case with the issue you're seeing as well. You'll need to flush privileges and restart MySQL if you make the recommended changes from the linked resource.