Forum Moderators: coopster
I've done some maintenance work on a clients database locally - and the connecting .php pages - on my local box and have tested, tested, tested.
Works perfect.
Then I deployed the changes. First I deleted the entire DB on the live site via my hosts MyPHPAdmin application - maybe I shouldn't have done that - did a mysql dump of my local DB via sqlyog and uploaded the dump live to the host.
I took a look at the live database and everythings there but my .php pages are not able to read the DB.
Could it be that when I deleted the old database that the password for that database has been deleted as well? If so, does anyone know how I can set a password for the new live database via myphpadmin?
Is there anything else I can consider to solve this immediate problem?
Anxiously awaiting anyones advice.
Neophyte
On your computer you probably have a database named "database" for instance.
On a server where there are multiple websites, they often append "username_" before everything dealing with mySQL.
So your mySQL username would be "username_mySQLusername" and your database would be "username_database".
Where "username" is the username they have to log into their control panel.
Just a thought.
You have to add each user to the database with the proper priviliges. I'm not sure if this is part of myPhpAdmin or if it is part of the control panel I use, but they have a GUI to do this.
If you still can't figure it out you should go into your php.ini and change the error reporting to show all errors so you can debug this problem.
Now I've started from scratch:
I've deleted mysql and phpmyadmin from the host and reinstalled both.
When I reinstalled mysql, it asked for a password so I gave it "jamesda".
In SQLyog, I re-exported the database on my local box, then I re-imported it via phpmyadmin.
It re-imported perfectly. I can see all data in each of the tables and can even do queries from within phpmyadmin on my live host.
I've checked my connect script which is as follows:
<?php
$db_host = "localhost";
$db_user = "root";
$db_pass = "jamesda";
$db_name = "danielik";
$db = mysql_connect($db_host, $db_user, $db_pass);
mysql_select_db($db_name, $db)or die('Unable to select database');
?>
I've re-uploaded the script, but when I try to load the site, now I get: "Unable to select database".
This makes me feel slightly better, but only slightly.
As I said in my first post, my connect script is exactly the same as is shown above, and the password I input both above and when I reinstalled mysql is the same as well.
Before I did the maintenance, it worked flawlessly on the live host.
Roldar...or anyone...where am I going wrong?
Neophyte
$db = mysql_connect($db_host, $db_user, $db_pass)
I have a feeling this is where the real problem is.
---------
<edit>
Okay I see you've solved the problem :)
I'm not sure if you always use the root user, but I would highly recommend that you don't. I only give the fewest priviliges to my users so that if something goes wrong or somebody hacks me they won't be able to do quite as much. Root has the ability to drop your database in a tiny little sql query.
Glad you've got things working!
</edit>