Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.
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.

mysql> 

Suppose the remotehost's OS is linux,

how do I switch to shell mode?

UPDATE

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.

share|improve this question
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
add comment

6 Answers

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
    
I've updated with more info. –  apache May 22 '10 at 14:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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