Forums / General Questions / Accidentally deleted DB but can not connect to restored DB

Accidentally deleted DB but can not connect to restored DB

Started by spyderrobotics on 10 Jan 2016, 12:59 AM · Views: 1,354

Results 1 to 8 of 8
10 Jan 2016, 12:59 AM
#1
spyderrobotics avatar

spyderrobotics

New Zenner

Join Date:
Oct 2007
Posts:
78
Plugin Contributions:
0

Accidentally deleted DB but can not connect to restored DB

I am in the process of changing host providers. I used cpanel to do a backup of my current site (1.50 zen). I also used phpmyadmin and backed up my database that way with the drop tables option. In the process of trying to get things going I accidentally deleted the database on my main site. So I went into cpanel and created a new database with the same name and user credentials that were in my configure.php files. I then used phpmyadmin to import the database. When I go to the store site I get:

There seems to be a problem connecting to our database.

When I go to the admin I get:

WARNING: An Error occurred, please refresh the page and try again.

I did not delete any of the files on the site. Only the database. I have triple checked and the DB name/username/password are correct in cpanel. I also deleted that database and did a restore database option in cpanel selecting the sql file from the "full backup" option. Any ideas? I appreciate any help.

10 Jan 2016, 2:11 AM
#2
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Accidentally deleted DB but can not connect to restored DB

Check your 2 configure.php files for this part:

// define our database connection
  define('DB_TYPE', 'mysql');
  define('DB_PREFIX', 'zen_');
  define('DB_CHARSET', 'utf8');
  define('DB_SERVER', 'localhost');
  define('DB_SERVER_USERNAME', 'your_username');
  define('DB_SERVER_PASSWORD', 'your_password');
  define('DB_DATABASE', 'your_DB_name');

Do all the definitions match your DB on the server?

Make sure all definitions match - including DB_PREFIX !

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

10 Jan 2016, 2:52 AM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Accidentally deleted DB but can not connect to restored DB

The actual error being encountered by PHP will be recorded in your /cache/ or /logs/ folder, as explained in these articles:
http://www.zen-cart.com/content.php?311-warning-an-error-occurred-please-refresh-the-page-and-try-again
http://www.zen-cart.com/content.php?124-blank-page

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

10 Jan 2016, 5:48 AM
#4
spyderrobotics avatar

spyderrobotics

New Zenner

Join Date:
Oct 2007
Posts:
78
Plugin Contributions:
0

Re: Accidentally deleted DB but can not connect to restored DB

The define settings are correct in my two configs. I checked the logs and found:```
[09-Jan-2016 23:39:25] PHP Fatal error: 0:DB_ERROR_NOT_CONNECTED :: select * from project_version WHERE project_version_key = 'Zen-Cart Database' in /home2/spyder12/public_html/store/includes/classes/db/mysql/query_factory.php on line 101


Also another curious thing was my original configs just had the path as /home not /home2.  I did try changing those paths to /home2... and got the same issue.
10 Jan 2016, 7:47 AM
#5
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Accidentally deleted DB but can not connect to restored DB

spyderrobotics:

The define settings are correct in my two configs. I checked the logs and found:```
[09-Jan-2016 23:39:25] PHP Fatal error: 0:DB_ERROR_NOT_CONNECTED :: select * from project_version WHERE project_version_key = 'Zen-Cart Database' in /home2/spyder12/public_html/store/includes/classes/db/mysql/query_factory.php on line 101


Is this the only line in that log file?

Also pls post the content of your /includes/version.php file

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

10 Jan 2016, 7:51 AM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Accidentally deleted DB but can not connect to restored DB

spyderrobotics:

The define settings are correct in my two configs. I checked the logs and found:```
[09-Jan-2016 23:39:25] PHP Fatal error: 0:DB_ERROR_NOT_CONNECTED :: select * from project_version WHERE project_version_key = 'Zen-Cart Database' in /home2/spyder12/public_html/store/includes/classes/db/mysql/query_factory.php on line 101

> 
> Also another curious thing was my original configs just had the path as /home not /home2.  I did try changing those paths to /home2... and got the same issue.
Definitely have the wrong db credentials (some hosts inject a wildcard to database names and db usernames ... like drbyte_ so, if you're naming your db as "zendb" and have a host-added wildcard of "drbyte_" then your db would be "drbyte_zendb". Similar concept with db usernames.), or you've got a mysql db user that hasn't been granted any permissions to that specific database.  If you deleted the db, it probably deleted the granted permissions for that db. You'll need to re-Grant permissions to that db user for that specific db.

<https://www.zen-cart.com/content.php?341-0-DB_ERROR_NOT_CONNECTED>

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

10 Jan 2016, 6:56 PM
#7
spyderrobotics avatar

spyderrobotics

New Zenner

Join Date:
Oct 2007
Posts:
78
Plugin Contributions:
0

Re: Accidentally deleted DB but can not connect to restored DB

I had the credentials right. I spent hours redoing this. I did get it back online. I used a new install of zc in a different folder with a new database (same db username/permissions). Everything worked. I was able to point my old install to that new database. Everything worked. I imported my old database into the new one. Everything worked. So something was broke in my other DB. I had tried two ways of importing the DB. One directly through the backup option in cpanel and and another article that said to create a new DB then go into it and drop the tables so that its blank and then import your old tables. I believe when I created my last one I just imported the old tables over the top of the default ones. I don't know if there is a difference there. So long story short the old site is back online now I just got to work out the bugs in the new site. I will post a new thread on that which involves the passwords not updating after the upgrade. Thanks for the time and ideas!

10 Jan 2016, 10:02 PM
#8
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Accidentally deleted DB but can not connect to restored DB

spyderrobotics:

I had the credentials right. I spent hours redoing this. I did get it back online. I used a new install of zc in a different folder with a new database (same db username/permissions). Everything worked. I was able to point my old install to that new database. Everything worked. I imported my old database into the new one. Everything worked. So something was broke in my other DB. I had tried two ways of importing the DB. One directly through the backup option in cpanel and and another article that said to create a new DB then go into it and drop the tables so that its blank and then import your old tables. I believe when I created my last one I just imported the old tables over the top of the default ones. I don't know if there is a difference there. So long story short the old site is back online now I just got to work out the bugs in the new site. I will post a new thread on that which involves the passwords not updating after the upgrade. Thanks for the time and ideas!

Thanks for the feedback that this now working for you.

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.