Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Database/World Building

Development::Database/World Building World Building forum, dedicated to the EQEmu MySQL Database. Post partial/complete databases for spawns, items, etc.

Reply
 
Thread Tools Display Modes
  #1  
Old 01-04-2010, 05:13 PM
eski2
Hill Giant
 
Join Date: May 2008
Location: sydney
Posts: 177
Default SQL for beginners! How do you backup and restore a db?

I haven't seen any decent sites on it yet and I can't find anyone locally who uses it still (everyone says "I used to know how to do that...")

Looking at what ChaosSlayerZ did below I can see how to multiply something by a value, but I'm not sure how to set something to a constant.

"update loottable_entries set multiplier=multiplier*2;"

I suspect it's something like
Code:
UPDATE `PEQ`.`items` SET `loregroup`='0';
if i wanted to remove the lore tag from everything but i don't know how to backup and restore my version of the peq db if i am stuffing up, and the intro web sites never seem to think a student would need to.

Can anyone tell me how to backup/restore, and if they think my code makes sense? Or at least of a decent training website that covers that sort of thing? I guess backup/restore is the main thing.
Reply With Quote
  #2  
Old 01-04-2010, 05:31 PM
Derision
Developer
 
Join Date: Feb 2004
Location: UK
Posts: 1,540
Default

I do my backups/restores via the command prompt.

To backup, use mysqldump. My database in this example is called ykesha rather than peq, so wherever you see ykesha, change it to peq or whatever you called your database:

Code:
C:\Users\Steve>mysqldump -u root -p ykesha > ykesha-backup.sql
Enter password: ******

C:\Users\Steve>
Your entire database is now backed up to the file called ykesha-backup.sql It's a text file, so you can browse through it with notepad.

In the event you wanted to restore that backup, you would go into the mysql command line tool, drop the database and re-create it (empty) and then source in the backup you made earlier, e.g.:

Code:
C:\Users\Steve>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.1.31-community MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> drop database ykesha;
Query OK, 0 rows affected (0.00 sec)

mysql> create database ykesha;
Query OK, 1 row affected (0.00 sec)

mysql> use ykesha;
Database changed
mysql> source ykesha-backup.sql


<lots of output snipped>
Also, your syntax for changing loregroups is fine. You can omit the `PEQ` prefix if you execute the use peq command first, e.g.:

Code:
C:\Users\Steve>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.1.31-community MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use peq
Database changed
mysql> update items set loregroup = 0;
Query OK, 33176 rows affected (1.91 sec)
Rows matched: 76214  Changed: 33176  Warnings: 0

mysql>
Reply With Quote
  #3  
Old 01-04-2010, 05:40 PM
eski2
Hill Giant
 
Join Date: May 2008
Location: sydney
Posts: 177
Default

Thanks very much, I'll give it a go!
Reply With Quote
  #4  
Old 01-04-2010, 06:44 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Also, if you use Navicat for managing your database, you can just right click on the database and select the "Dump to SQL" option. Then, chose a name to save it as and run it. That will back the DB up just like the command prompt way that Derision described.

Then, to restore your database, you can just right click on the database in Navicat and select the "Run Batch File" option (not sure if that is the exact name of the option, but it is something like that). Then, select the backup you wish to restore to and run it.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #5  
Old 01-04-2010, 06:52 PM
Secrets's Avatar
Secrets
Demi-God
 
Join Date: May 2007
Location: b
Posts: 1,450
Default

Something else to note is the --opt flag in MySQL. It makes sourcing a lot faster with MySQLDump as it does more than one entry per line, amongst other things.

Code:
mysqldump -u root -p ykesha --opt
Reply With Quote
  #6  
Old 01-05-2010, 07:49 PM
Rogean's Avatar
Rogean
Administrator
 
Join Date: Jul 2003
Location: Massachusetts
Posts: 708
Default

http://lmgtfy.com/?q=mysqldump
__________________
EQEmulator Developer / Administrator
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 01:21 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3