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 [email protected] and then type sudo mysql -u mysqluser -p
It give me access denied to [email protected] 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 [email protected] , 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.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct