Zen Cart Logo
Forums / General Questions / Can I close the store for maintenance... from the database?

Can I close the store for maintenance... from the database?

Views: 1,134

Results 1 to 18 of 18
3 Dec 2012, 3:55 AM
#1
jenpen avatar

jenpen

Zen Follower

Join Date:
Sep 2007
Location:
Far South Coast, NSW, Australia
Posts:
427
Plugin Contributions:
0

Can I close the store for maintenance... from the database?

Hello,
Interesting one, this.
Our admin has disappeared - all I'm getting in the installation screen - although the store is still up and appears to be working fine. I can see that admin/includes/configure.php has lost all its connection details, but when I correct them, the file reverts to "localhost" etc upon saving.
So I want to back up the files and database so I can reinstall, but first I need to close the store for maintenance. Can I do this from the database in phpMyadmin?

3 Dec 2012, 8:10 AM
#2
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: Can I close the store for maintenance... from the database?

When you save your confiure.php to the server. did you remember to make it writeable (664 or 666) first? Otherwise your changes will not be saved on the server.

3 Dec 2012, 8:39 AM
#3
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Can I close the store for maintenance... from the database?

jenpen:

but first I need to close the store for maintenance. Can I do this from the database in phpMyadmin?

Yes. Run the following SQL command

UPDATE configuration set configuration_value = 'true' where configuration_key = 'DOWN_FOR_MAINTENANCE';

Cheers
Rod

4 Dec 2012, 4:54 AM
#4
jenpen avatar

jenpen

Zen Follower

Join Date:
Sep 2007
Location:
Far South Coast, NSW, Australia
Posts:
427
Plugin Contributions:
0

Re: Can I close the store for maintenance... from the database?

Thanks Design75 but yes, it was writeable. My changes disappear upon Save. But thanks RodG, that exactly what I need.

4 Dec 2012, 5:20 AM
#5
jenpen avatar

jenpen

Zen Follower

Join Date:
Sep 2007
Location:
Far South Coast, NSW, Australia
Posts:
427
Plugin Contributions:
0

Re: Can I close the store for maintenance... from the database?

Guys, I exported the DB, reinstalled ZC and have just tried to import the DB. But I'm getting:
Error

SQL query:

--
-- Dumping data for table address_format

INSERT INTO address_format ( address_format_id , address_format , address_summary )
VALUES ( 1, '$firstname $lastname$cr$streets$cr$city, $postcode$cr$statecomma$country', '$city / $country' ) , ( 2, '$firstname $lastname$cr$streets$cr$city, $state $postcode$cr$country', '$city, $state / $country' ) , ( 3, '$firstname $lastname$cr$streets$cr$city$cr$postcode - $statecomma$country', '$state / $country' ) , ( 4, '$firstname $lastname$cr$streets$cr$city ($postcode)$cr$country', '$postcode / $country' ) , ( 5, '$firstname $lastname$cr$streets$cr$postcode $city$cr$country', '$city / $country' ) , ( 6, '$firstname $lastname$cr$streets$cr$city$cr$state$cr$postcode$cr$country', '$postcode / $country' ) ;

MySQL said: Documentation
#1062 - Duplicate entry '1' for key 1

What to do?

4 Dec 2012, 6:08 AM
#6
jenpen avatar

jenpen

Zen Follower

Join Date:
Sep 2007
Location:
Far South Coast, NSW, Australia
Posts:
427
Plugin Contributions:
0

Re: Can I close the store for maintenance... from the database?

I just tried the same import again. This time it's giving the same error message but there are real names and addresses in the data.

4 Dec 2012, 11:01 PM
#7
jenpen avatar

jenpen

Zen Follower

Join Date:
Sep 2007
Location:
Far South Coast, NSW, Australia
Posts:
427
Plugin Contributions:
0

Re: Can I close the store for maintenance... from the database?

I'm stuck here, so if anyone can cast some light, please don't hold back :dontgetit

5 Dec 2012, 7:42 AM
#8
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Can I close the store for maintenance... from the database?

jenpen:

I'm stuck here, so if anyone can cast some light, please don't hold back :dontgetit

Option1: Delete the data from the table before trying to import new data.
Option2: Assuming the data that already exists in the table is valid, then simply ignore this error.

Oh, there should not be real names in the import data. The data contains variable names only.

Cheers
Rod

6 Dec 2012, 11:35 PM
#9
jenpen avatar

jenpen

Zen Follower

Join Date:
Sep 2007
Location:
Far South Coast, NSW, Australia
Posts:
427
Plugin Contributions:
0

Re: Can I close the store for maintenance... from the database?

RodG, excuse this phpMyadmin amateur, but I am having trouble deleting the whole database. I know the SQL for deleting from a table, so I'm trying to use that, ie delete from 'prefix_databasename'. But I get a syntax error. I guess I could delete each table one by one, but trying to avoid that.

7 Dec 2012, 12:49 AM
#10
drbyte avatar

drbyte

Sensei

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

Re: Can I close the store for maintenance... from the database?

You're supposed to "Include DROP/CREATE TABLE IF EXISTS" support when you're doing your backup. See: http://www.zen-cart.com/content.php?144-how-can-i-do-a-site-backup-or-use-phpmyadmin-for-database-backup

If you didn't do that, then you'll need to "drop" all your normal Zen Cart tables before you can import data back into them. Hopefully your backup at least includes "CREATE TABLE" statements. If not, then you'll be an even bigger pickle.

7 Dec 2012, 12:56 AM
#11
jenpen avatar

jenpen

Zen Follower

Join Date:
Sep 2007
Location:
Far South Coast, NSW, Australia
Posts:
427
Plugin Contributions:
0

Re: Can I close the store for maintenance... from the database?

Thanks Dr Byte. I just did a regular "Export" on the database so I don't know what was included. I was confident because over the years I have moved zen carts around different servers dozens of times and they always slotted right back into the new database when I needed them to. But the database on the new server has always been empty.

So how do I "drop" all my normal Zen Cart tables?

7 Dec 2012, 1:25 AM
#12
drbyte avatar

drbyte

Sensei

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

Re: Can I close the store for maintenance... from the database?

Put a checkmark in the box next to each Zen Cart table, then choose "drop" from the menu below all the checkboxes.

7 Dec 2012, 2:54 AM
#13
jenpen avatar

jenpen

Zen Follower

Join Date:
Sep 2007
Location:
Far South Coast, NSW, Australia
Posts:
427
Plugin Contributions:
0

Re: Can I close the store for maintenance... from the database?

Thanks, all fixed now. :D

7 Dec 2012, 3:39 AM
#14
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Can I close the store for maintenance... from the database?

jenpen:

I am having trouble deleting the whole database.

I see that this problem has been solved. :)

Another solution (one that I would have used) would be to rename (not copy) the database to something like "mydatabase_original" then create a new "mydatabase" database. You just never know when you'll need this as a backup.

As a "phpMyadmin amateur" it pays to experiment. All those import/export options are there for a reason. Most you'll never need to touch, but some, like the "Include DROP/CREATE TABLE IF EXISTS" is a double edged sword. In this case it is something you** want **it to do. In other cases it is easy to unintentionally delete things you didn't intend too.

Cheers
Rod

8 Dec 2012, 5:50 AM
#15
jenpen avatar

jenpen

Zen Follower

Join Date:
Sep 2007
Location:
Far South Coast, NSW, Australia
Posts:
427
Plugin Contributions:
0

Re: Can I close the store for maintenance... from the database?

I guess I've always got it as a back-up - as an SQL file on my hard drive.
Is the "Include DROP/CREATE TABLE IF EXISTS" bit in here somewhere?Attachment 11602

8 Dec 2012, 6:17 AM
#16
drbyte avatar

drbyte

Sensei

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

Re: Can I close the store for maintenance... from the database?

Yes. As the FAQ article says, you'll need to put a check in the "Add DROP TABLE .... statement" box.

8 Dec 2012, 6:32 AM
#17
jenpen avatar

jenpen

Zen Follower

Join Date:
Sep 2007
Location:
Far South Coast, NSW, Australia
Posts:
427
Plugin Contributions:
0

Re: Can I close the store for maintenance... from the database?

OK, got it, thanks.

8 Dec 2012, 8:34 AM
#18
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Can I close the store for maintenance... from the database?

jenpen:

I guess I've always got it as a back-up - as an SQL file on my hard drive.

One can never have too many backups. :)

Although not meant as a substitute for a 'real' backup, the idea of renaming rather than deleting is that the renamed backup is quicker and easier to restore. When you've finished whatever it is you are doing then you can delete the renamed database.. which brings us back to the original question, how to delete a database? <g>

Anyway, 'tis a tip I've often found useful, but then again, I also make a lot of stuff-ups so I'll probably find it more useful than most others ;)

Cheers
Rod