how to emulate "su mysql" in ubuntu?

Tom H tomh0665 at gmail.com
Wed Jul 28 18:36:51 UTC 2010


On Wed, Jul 28, 2010 at 12:44 PM, Patrick Doyle <wpdster at gmail.com> wrote:
> On Wed, Jul 28, 2010 at 12:25 PM, Tom H <tomh0665 at gmail.com> wrote:
>> On Wed, Jul 28, 2010 at 12:03 PM, Patrick Doyle <wpdster at gmail.com> wrote:
>>> On Wed, Jul 28, 2010 at 12:00 PM, Robert P. J. Day
>>> <rpjday at crashcourse.ca> wrote:
>>>> On Wed, 28 Jul 2010, Patrick Doyle wrote:
>>>>
>>>>> I see that sudo takes a -u argument, perhaps
>>>>>
>>>>> $ sudo -u mysql /bin/sh
>>>>>
>>>>> might do the trick.
>>>>
>>>>  yes, that appears to work, but i could *swear* that was also one of
>>>> the first things i tried.  i must have tested every subtle variation
>>>> of that except for that.  argh.  thanks.
>>>>
>>> And, of course, Marius Gedminas gave the more elegant solution of:
>>>
>>> $ sudo -u mysql -s
>>
>> sudo -s == su
>> sudo -i == su -
>>
>
> Just in case anybody stumbles across this thread sometime in the future...
>
> Tom & Marius go me curious, so I installed mysql-server on my Ubuntu
> 10.04 box an noticed that it created a mysql user with a login shell
> of /bin/false.
>
> So my first suggestion of
>
> $ sudu -u mysql /bin/sh
>
> would work, whereas using the -i and -s arguments wouldn't.  (Actually
> $sudo -u mysql -s bash seems to work.)

Good catch! :)

Although I hope that you mean sudo and not sudu. :)

I made the incorrect assumption that su was failing because the
password field in shadow was "!" or "*" (which may be the case too)
and didn't think of the shell... So "sudo -i" would definitely fail
since it calls on mysql's shell.

I didn't know that you could pass a command to "sudo -s"; thanks.




More information about the ubuntu-users mailing list