sudo su to start
mysql and do some homework with it.
When I finish with
mysql (or any other command), then I'm still in
How do I "log out", so my prompt changes back from
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
You don't need to use
su switches your user account (without arguments it switches you to root).
sudo just elevates your privileges to root for the current command.
It's reccomended to use
sudo instead of
su if possible, but to return to your normal account after calling
su, simply use the
There isn't any reason to use
su to run the MySQL command-line client. It defaults to using your current Unix user as your MySQL user, but instead you should pass it the user you want to connect to as arguments:
$ mysql -u root # connect as MySQL's root user (without password) $ mysql -u root -p # -p means prompt for a password
Hopefully, your MySQL root account has a password, and you'll need to use the second form.
Other than that, if you need to run MySQL under sudo (e.g., for file permissions) then do it like this:
$ sudo -u unix-user mysql -u mysql-user -p
You can leave out the arguments (sudo will default to user root, MySQL will default to using the same user as sudo).
if you get access denied message -for example - while login to mysql with root password like:
mysql -u root -p
sudo mysql -u root -p
for one time elevation of privileges, for multiple commands use:
you will notice that your terminal changed to [root@yourpc]# then whatever commands you like to run when you want to return back to your own user hit ctrl + d , type exit or
your terminal will be back to [username@yourpc]# and you are now using you own user permissions