mysql -u user -p pass -h remotehost
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 96
Server version: 5.1.36-community-log MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


Suppose the remotehost's OS is linux,

how do I switch to shell mode?


I get access to database via shell prompt.

I meant to access shell prompt of remotehost,typing exit will return to my own shell prompt.

  • 1
    Have you simply tried "exit"? – Antoine Benkemoun May 22 '10 at 13:43
  • 2
    Do you have a system account at remotehost? (The mysqld user database is generally completely separate from the system user database.) – andol May 22 '10 at 13:54

Having database access doesn't imply that you have shell access. I have a a database at work to which many co-workers have access with some user/password combination. However, none of them have a shell login, because they don't need it.


A MySQL connection and a "shell" connection are completely independent, even if they appear to go to the same address. You can't switch from one to other directly; you have to exit the MySQL client and start a SSH client in its place.


mysql -u user -p pass -h remotehost

I take it you connecting by running the above command from your own machine..

There is no way to gain remote system shell access from within the mysql shell, so unless you have not been provided with a system login account for the remote host you are probably out of luck.

Provided a login account you could typically use SSH or telnet to access the remote host.


You fail to describe how you "got database access". If it was by executing the mysql client from a shell prompt, then simply exiting the mysql console will drop you back to the shell. However, if your database access is over the web (e.g. phpmyadmin), you can't just "switch to shell".

More info needed.

  • I've updated with more info. – apache May 22 '10 at 14:08

You cannot get to a shell from the MySQL monitor, for security reasons. Unless the system authenticates against the database using pam_mysql, and you can add new database users (it's ridiculously unlikely that both would be true, due to security concerns), you are out of luck.


Actually if the mysql is run as a root user and you have specific privileges, then you could but it would also get you in a boat load of trouble considering it would grant you the same user access as the mysql account itself.

Because the only reason you would even do what I am think is to gain access to a system you don't have the privileges or rights to, I won't say how because that would be unethical but I can say for sure there is a way.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.