Ubuntu: sudo su doesn't change users for mysql



Question:

Last night, on my server, I did:

sudo su - mysql   

to change to the mysql user so I could run the mysql client, which is set up so it will only authenticate from the mysql account. I successfully ran the mysql client and made the change to the database. Nothing changed on the server overnight.

Today, nothing I try will allow my to change to the mysql user. It appears to succeed, given the message about no home directory, but whoami still reports my user id and trying to run mysql still fails.

wade@snoopy:~$ sudo su - mysql  [sudo] password for wade:   No directory, logging in with HOME=/  wade@snoopy:~$ whoami  wade    wade@snoopy:~$ sudo su mysql  wade@snoopy:~$ whoami  wade    wwilliam@snoopy:~$ sudo -s  root@snoopy:/home/wade#   root@snoopy:/home/wade# su mysql  root@snoopy:/home/wade# whoami  root  

/etc/passwd for mysql:

mysql:x:110:119:MySQL Server,,,:/nonexistent:/bin/false  

Has anyone ever seen behavior like this?


Solution:1

su invokes the other user's login shell as given in /etc/passwd. In your case that's /bin/false so you don't get any interactive shell.

Use

sudo -u test /bin/bash  

or

sudo -u test /usr/bin/mysql  

or something like that instead.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »