1

I was visiting a mysql installation (don't know the details)

[user@host ~]$ mysql -u kco -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'kco'@'localhost' (using password: YES)

Checked, and password I was given seems correct. I noticed in the sample I'd been given, they had been running as root.

[user@host ~]$ sudo mysql -u kco -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'kco'@'localhost' (using password: YES)

[Sudoers has wheel with NOPASSWD.] Ok, that's not it. Or is it?

[user@host ~]$ sudo su
[root@host user]# mysql -u kco -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 196356
Server version: 5.1.73 Source distribution

Odd. Thought it might be a socket permission thing, but

[root@host user]# ls -l /var/lib/mysql/mysql.sock
srwxrwxrwx. 1 mysql mysql 0 Mar 19 18:39 /var/lib/mysql/mysql.sock

Hm. Got a quick downvote, so let me be more explicit in the question. The desired result would be for a regular user to be able to mysql -u kco -p . Why does it require a root shell (not sudo) to access the UI?

  • sudo is modifying the linux user, mysql -u databaseUser -p is a user setup in mysql. Normally mysql does not require linux root access, sudo. Only a mysql user who may have mysql root access. Example able to create and delete databases. – jc__ May 30 '18 at 14:13
  • I understand, that's why this is puzzling. Authentication and authorization in mysql is controlled by entries in a table, and should have nothing to do with effective uid; and the sudo mysql should not be different from sudo su then mysql. Yet that is the observed behaviour... – Woody Weaver Jun 2 '18 at 3:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.