Problem solve Get help with specific problems with your technologies, process and projects.

Script can't connect to MySQL, only works when logged in via SHH/Shell

I am running a cgi script on an ISP-hosting server that accesses a MySQL database. This script works fine when...

using anyother type of database, but when I try to set it up for MySQL, it cannot connect. Here is where it gets interesting: When log I onto my server space via SHH/Shell access everything works FINE! And the script can access the SQL database no problem... it's only when I'm not logged onto SHH/Shell that I have a problem.

What would signing into SHH/Shell change as far as accessing MySQL and hence give me some idea how to fix this?

More info:

  • The script is owned by my user (bsharp)
  • The MySQL.sock is owned by user MySQL
  • The actual database I created is owned by MySQL
  • I'm using a perl command like DBI:mySQL:database:host
The user I am using to access MySQL ('bsharp_intchg') can connect on other MySQL access programs (such as Navicat by Premiumsoft). I don't think there is a problem with the user or password. I have tried adding the host % to the allowable connection hosts. I don't think this is too important but:
  • The script is the gnu INTERCHANGE ecomerce dameon
  • My hosting provider uses cpanel
I guess my question is what does this problem -- only working when logged in --mean? And how should I go about fixing it?

Many ISPs do not allow access to port 3306 (the MySQL server TCP/IP port) from outside their firewall. If this is the case, you can still attempt remote access by using SSH tunneling. I have a tutorial on the subject (in a Windows context) at http://www.vbmysql.com/articles/security/sshtunnel.html, and a Web search on the subject should yield a variety of other tutorials.

For More Information

This was last published in May 2004

Dig Deeper on Linux servers



Find more PRO+ content and other member only offers, here.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.