Full Version: How to test if MySQL database is working
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
There is a simple way that you can test whether or not you can establish a connection on your MySQL database with your created username and password

Simply create a .php file (e.g. connect.php) with the following code:

mysql_connect("localhost", "db_username", "db_passwd") or die(mysql_error());
echo "Connected to MySQL<br />";
mysql_select_db("db_name") or die(mysql_error());
echo "Connected to Database";

Note that you need to replace

db_username with the username associated with the database
db_passwd with the password for the database user


db_name with the name of the database you have created

When you upload the file, point your web browser to (replacing 'connect.php' with the name of the php file you saved it as) and it should print to the screen with success assuming that it managed to connect.
Reference URL's