WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Database Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Database Discussion Forum This is the place to find help resolving those nagging questions you have about implementing and using all kinds of databases. Need help writing a query? Need an opinion on Oracle? Post here!

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-23-2007, 02:05 PM
spenland spenland is offline
WebProWorld Pro
 

Join Date: Jul 2004
Location: Irvine, CA
Posts: 120
spenland RepRank 0
Default How to import a .bak file into a new SQL server

Hi everyone, I'm not very well versed in SQL. I've been given a .bak file that is a backup of a clients database. I need to upload this file to a NEW server. I have abosultely no idea how to do this. I've read through some posts and some people have mentioned a "RESTORE" command but I really just don't know what I'm doing. Can someone help me with this?

Thanks!
Reply With Quote
  #2 (permalink)  
Old 08-23-2007, 02:53 PM
wige's Avatar
wige wige is offline
Moderator
WebProWorld Moderator
 

Join Date: Jun 2006
Location: United States
Posts: 1,648
wige RepRank 4wige RepRank 4wige RepRank 4
Default Re: How to import a .bak file into a new SQL server

What type and version of SQL server is the backup from, and what version are you uploading to?
__________________
The best way to learn anything, is to question everything.
Interestingly Average Security Blog
Reply With Quote
  #3 (permalink)  
Old 08-23-2007, 03:42 PM
spenland spenland is offline
WebProWorld Pro
 

Join Date: Jul 2004
Location: Irvine, CA
Posts: 120
spenland RepRank 0
Default Re: How to import a .bak file into a new SQL server

I'm not sure what the original backup was made under but the version of SQL on my server is MySQL 4.1.22-log.
Reply With Quote
  #4 (permalink)  
Old 08-23-2007, 05:05 PM
wige's Avatar
wige wige is offline
Moderator
WebProWorld Moderator
 

Join Date: Jun 2006
Location: United States
Posts: 1,648
wige RepRank 4wige RepRank 4wige RepRank 4
Default Re: How to import a .bak file into a new SQL server

If the backup is a text file consisting of MySQL commands, you should be able to do this locally through a shell by entering
Code:
mysql -u username -ppassword database_name < file.bak
Note there is no space between "-p" and your password.

If you have a utility like phpMyAdmin, there is also a utility for recovering from a backup built in.
__________________
The best way to learn anything, is to question everything.
Interestingly Average Security Blog
Reply With Quote
  #5 (permalink)  
Old 08-23-2007, 05:06 PM
spenland spenland is offline
WebProWorld Pro
 

Join Date: Jul 2004
Location: Irvine, CA
Posts: 120
spenland RepRank 0
Default Re: How to import a .bak file into a new SQL server

Thanks, but I don't know how to run shell commands. I'm using PHPMyAdmin so if there is a way to restore the database through it that would be great.
Reply With Quote
  #6 (permalink)  
Old 08-23-2007, 05:22 PM
wige's Avatar
wige wige is offline
Moderator
WebProWorld Moderator
 

Join Date: Jun 2006
Location: United States
Posts: 1,648
wige RepRank 4wige RepRank 4wige RepRank 4
Default Re: How to import a .bak file into a new SQL server

See Backup and Restore of MySql database with phpMyAdmin for instructions. If the backup file is too large, the only option may be using command line tools, which may mean the hosting company has to do it for you.
__________________
The best way to learn anything, is to question everything.
Interestingly Average Security Blog
Reply With Quote
  #7 (permalink)  
Old 08-23-2007, 05:32 PM
spenland spenland is offline
WebProWorld Pro
 

Join Date: Jul 2004
Location: Irvine, CA
Posts: 120
spenland RepRank 0
Unhappy Re: How to import a .bak file into a new SQL server

Funny that you sent that link as I did a google search earlier and followed the instructions on that page. Unfortunately I was not successful in importing the database by following those directions and I received a weird error saying that I may have found a bug in the MYSQL software!

I'm wondering if its because the database names are not the same. My host, aplus.net, doesn't allow you to name your database it just automatically creates one named after your FTP username.

So if my database is named "example1" and the database I'm importing is named "database1B" will I have problems?
Reply With Quote
  #8 (permalink)  
Old 08-23-2007, 06:32 PM
computergenius computergenius is offline
WebProWorld Veteran
 

Join Date: Jul 2003
Location: Spain
Posts: 327
computergenius RepRank 1
Default Re: How to import a .bak file into a new SQL server

You will have problems if the database name is in your SQL file (what you call your bak file)

How big is the file? Are you aware that it is a text file, and that if you have a suitable editor, you can edit A COPY OF (!) the file. If the file contains the "use database" command, you can just delete it, as you have already told PHPMyAdmin which database to use.

The SQL file should contain a CREATE statement for each table, together with the INSERT commands for all the records.
__________________
Pete Clark
Sunny Southern Spain - http://hotcosta.com/Andalucia.Spain
Reply With Quote
  #9 (permalink)  
Old 08-23-2007, 07:01 PM
spenland spenland is offline
WebProWorld Pro
 

Join Date: Jul 2004
Location: Irvine, CA
Posts: 120
spenland RepRank 0
Default Re: How to import a .bak file into a new SQL server

The file is only 2.5 MB. It is weird because i opened up the file in notepad and it appears as if there are alot of erroneous characters and crap in the file. I saw no CREATE or any other SQL type statements. I'm wondering if the network guy #$%# up when backing this up.

When I try to import into PHPmyAdmin i get this error.

"There is a chance that you may have found a bug in the SQL parser. Please examine your query closely, and check that the quotes are correct and not mis-matched. Other possible failure causes may be that you are uploading a file with binary outside of a quoted text area. You can also try your query on the MySQL command line interface. The MySQL server error output below, if there is any, may also help you in diagnosing the problem. If you still have problems or if the parser fails where the command line interface succeeds, please reduce your SQL query input to the single query that causes problems, and submit a bug report with the data chunk in the CUT section below:"
Reply With Quote
  #10 (permalink)  
Old 08-24-2007, 03:52 AM
seiretto's Avatar
seiretto seiretto is offline
WebProWorld Pro
 

Join Date: Nov 2006
Location: Huddersfield, Yorkshire, UK
Posts: 109
seiretto RepRank 0
Default Re: How to import a .bak file into a new SQL server

That sounds like the file is a .gz (gzip) or .zip file.

Try copying the file and renaming it with a .gz and .zip extension (ie. myfile.gz, and myfile.zip) and try an import again on those.

If it times-out try this:
DWalker.co.uk :: View topic - Large MySQL database restore - server timing out? Try this

Hope that helps
__________________
Experienced UK website host hosting sites for over a decade; Need to host mutliple domains and websites check out our Reseller hosting or try our UK managed servers
Reply With Quote
  #11 (permalink)  
Old 08-24-2007, 09:13 AM
wige's Avatar
wige wige is offline
Moderator
WebProWorld Moderator
 

Join Date: Jun 2006
Location: United States
Posts: 1,648
wige RepRank 4wige RepRank 4wige RepRank 4
Default Re: How to import a .bak file into a new SQL server

There are several different ways to create a backup of a MySQL database. The most common is what has been discussed mostly above and which is covered in the documentation mentioned. This creates a single text file that lists all the SQL commands needed to recreate the database as it was. Other methods include simply taking the actual database data files from the original server and compressing and archiving them. This is usually less than ideal because you can run into problems with differences between versions of MySQL.

Does the original database still exist somewhere, or is it only in the backup file?
__________________
The best way to learn anything, is to question everything.
Interestingly Average Security Blog
Reply With Quote
  #12 (permalink)  
Old 08-24-2007, 02:29 PM
spenland spenland is offline
WebProWorld Pro
 

Join Date: Jul 2004
Location: Irvine, CA
Posts: 120
spenland RepRank 0
Default Re: How to import a .bak file into a new SQL server

Thanks for your responses guys. The database does still exist but I've had a very difficult time connecting to it. This database is on a different server than the website.

If I want to access the FTP web server, i just plug in the website, username, and password and I'm in no problem. However, for the database I was told to use:

unixsql2.interl.net

When I try to connect through MySQL Front, I get an error. What could I be missing that is not allowing me to connect?
Reply With Quote
  #13 (permalink)  
Old 08-24-2007, 03:44 PM
wige's Avatar
wige wige is offline
Moderator
WebProWorld Moderator
 

Join Date: Jun 2006
Location: United States
Posts: 1,648
wige RepRank 4wige RepRank 4wige RepRank 4
Default Re: How to import a .bak file into a new SQL server

I'd have to see the documentation to know for sure, but I think this means that the database is stored on another server from your main site. The unixsql2.interl.net address is the URL that your scripts would use to talk to the server. This server probably has a firewall set up to only allow connections from the web servers. You should not be able to connect to that URL from anywhere else.
__________________
The best way to learn anything, is to question everything.
Interestingly Average Security Blog
Reply With Quote
  #14 (permalink)  
Old 08-24-2007, 05:14 PM
spenland spenland is offline
WebProWorld Pro
 

Join Date: Jul 2004
Location: Irvine, CA
Posts: 120
spenland RepRank 0
Unhappy Re: How to import a .bak file into a new SQL server

Yes I was afraid of that, oh well I guess I'll be doing some data entry this weekend.
Reply With Quote
  #15 (permalink)  
Old 08-24-2007, 06:15 PM
computergenius computergenius is offline
WebProWorld Veteran
 

Join Date: Jul 2003
Location: Spain
Posts: 327
computergenius RepRank 1
Default Re: How to import a .bak file into a new SQL server

Why not set up MySQL on your local Windows computer in your office? Use something like WAMP, it will just about set itself up. Then you can try loading the data without any restrictions.

When you have the data loaded in your own database, you can make a backup, which you can then load into the live database.

Much easier than re-typing all the data!
__________________
Pete Clark
Sunny Southern Spain - http://hotcosta.com/Andalucia.Spain
Reply With Quote
  #16 (permalink)  
Old 08-24-2007, 07:29 PM
hostBrain hostBrain is offline
WebProWorld Pro
 

Join Date: May 2007
Location: DataCenter
Posts: 174
hostBrain RepRank 1
Default Re: How to import a .bak file into a new SQL server

Installing Wamp on your desktop is a pretty good idea, and may come in handy in the future as well. YOu can get one here apache friends - xampp for windows

It would also be a good idea to find out what version of mysql the db is from, and how it was backed up
__________________
----Don't Call Me Brian----
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Database Discussion Forum
Tags: bak, file, import, server, sql



Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Import URL Addresses into Excel mkinzie1 Yahoo! Discussion Forum 2 02-20-2007 02:16 PM
Redirect .php file in IIS server akela007 Other Engines/Directories 2 01-03-2007 09:54 PM
how to import a abr-file into PhotoShop (brushes) leonievs Graphics & Design Discussion Forum 2 11-19-2004 06:37 AM
Import .eml files back to Yahoo! thestriker10 Yahoo! Discussion Forum 0 08-20-2004 11:11 AM
Can't import movie with sound into Flash MX? John Dowler Flash Discussion Forum 2 06-03-2004 07:59 AM


Search Engine Friendly URLs by vBSEO 3.0.0