Ask the Expert

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?

Requires Free Membership to View

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 first published in May 2004

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
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
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: