Web Hosting Forum - A Web Hosting community for Webmasters


Divi WordPress Theme

Author Topic: Simple MySQL Connection Testing Script  (Read 2546 times)

0 Members and 1 Guest are viewing this topic.

Offline Tech

  • Junior Guru
  • **
  • Posts: 183
  • iTrader: +2/-0
    • View Profile
Simple MySQL Connection Testing Script
« on: August 30, 2007, 02:04:54 AM »
If you run MySQL dependent applications, you have probably hit this scenario at some stage. You're trying to install some software that requires MySQL and are using the correct details; but a MySQL connection can't be made.

Your hosting service says the problem is in the installation routine of the software, the software author says it's your hosting service – and back and forth you go between host and vendor until someone finally accepts responsibility and fixes the issue. A lot of time can be wasted, and time is money; not to mention the great deal of frustration that can occur.

There's a simple script for testing connectivity that should help settle the issue. Here's what to do:

1. Check your hosting account control interface to ensure that the database is present and you have a user set up for that database. Also ensure you have the right password for the db.

2. Create an empty file with a text editor and save it as mysqltest.php

3. Add the following to that file:

Replace hostname (usually localhost), username and password with the details you have for your database. There's no need to add the database name.

4. Upload to your server to a folder that's viewable via a browser.

5. Load the file in your browser

If a connection is made, the resulting page will display ‘Connection OK'. Talk again with the software vendor and give them the URL to the script.

If a connection cannot be made, then you'll probably see something like:

Warning: mysql_connect(): Access denied for user ‘dbuser'@'localhost' (using password: YES) in /path/to/mysqltest.php on line 2 Could not connect to MySQL: Access denied for user ‘dbuser'@'localhost' (using password: YES)

Copy and paste that error and send it to your web host, along with the details of your database.

Don't forget to remove the file once the issue is settled.

Article Source: http://EzineArticles.com/?expert=Michael_Bloch
« Last Edit: January 01, 1970, 05:30:00 AM by Tech »

Divi WordPress Theme
Tags:
 

Related Topics

  Subject / Started by Replies Last post
1 Replies
3511 Views
Last post December 22, 2011, 05:52:05 PM
by wilsondavid
0 Replies
5939 Views
Last post November 30, 2008, 10:47:40 AM
by Kailash
0 Replies
31390 Views
Last post December 05, 2008, 10:16:16 PM
by Kailash
0 Replies
763 Views
Last post May 21, 2014, 01:07:06 PM
by MichaelNicolei
0 Replies
486 Views
Last post December 14, 2014, 07:53:50 PM
by wRick