views:

37

answers:

2

I had trouble installing a local installation of mysql, so I have a connection to a remote mysql database via an IP tunnel, I connect to it via typing localhost in perl and python scripts. Something weird is happening and I want to check the connection from the command line rather than the script. Is there a BASH command line that I can type to connect to the mysql db as localhost?

Thanks

+3  A: 

Err, have you tried the mysql client? It defaults to localhost if -h is not specified.

Alex
so I had a problem installing the mysql client on my machine, hence why I'm using the remote one. So I want to test the remote server rather than the localone, but since I'm using the tunnel, localhost goes to the tunneled machine.
John
You can specify `-h` to have any hostname or IP you like.
Alex
ok thanks, I see the command lines below.
John
+1  A: 

If you want to test MySQL commands from the command line then you will have to install the MySQL command line client.

Another option is to get MySQL GUI Tools, which includes the MySQL query browser. You can execute commands in the query browser just like on the command line.

If you just want to test if the port is open then you can try connecting to it using telnet or netcat:

nc localhost 3306

If the MySQL server is running and you can connect then you should see a version number and then some random characters. Then you will have to press Ctrl-C to cancel the connection. You can't execute SQL like this.

Mark Byers