Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Website and Server Administration Forum


You are currently viewing our Website and Server Administration Forum as a guest. Please register to participate.
Login



Reply
USB enclosure MySQL data dump
Old 02-06-2010, 10:00 AM USB enclosure MySQL data dump
bbrian017's Avatar
Super Talker

Posts: 110
Trades: 0
Operating System: CentOS 5
Processor: Intel Pentium 4 - 3.0 GHz
RAM: 1 GB
Total Disk Space: 120 GB
RAID: None
Bandwidth Quota: 500 GB

My server recently crashed and now I'm reprovisioning a new hard drive.

I paid the 150 USD to have a USB enclosure of the old hard drive.

How do I perform the following?

Export mysql from the websites on the hard drive?

EDIT: I found it.

EXPORT

Code:
# mysqldump -u username -ppassword database_name > FILE.sql
IMPORT

Code:
# mysql -u username -ppassword database_name < FILE.sql
BUT Where does this stuff get exported to?

How do I move it from the old hard drive to the new one?

So far I understand I have to mount the hard drive on to my new hard drive.

Code:
mkdir /olddrive
mount /dev/sdb3 /olddrive
I can use all the help if anyone has some free hanging around and helping time.

I figure if I can get help with the first website the other 8 will be no problem...
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

bbrian017 is offline
Reply With Quote
View Public Profile Visit bbrian017's homepage!
 
 
Register now for full access!
Old 02-06-2010, 10:54 AM Re: USB enclosure MySQL data dump
bbrian017's Avatar
Super Talker

Posts: 110
Trades: 0
I managed to successfully mount the hard drive and visit it's /home/ root

Please see attachment.

Questions

Am I looking at the sql data or physical files such as html, tpl, and php?

If it's SQL Data how do I see the physical files such as html, tpl, and php?

If it's the physical files such as html, tpl, and php how do I see the sql data?

I ran this,

# mysqldump -u username -ppassword database_name > blogengage.sql

It seem to have worked but I'm not sure where it put blogengage.sql

Thanks,

Brian
Attached Images
File Type: jpg root_old_drive.jpg (25.6 KB, 2 views)
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

bbrian017 is offline
Reply With Quote
View Public Profile Visit bbrian017's homepage!
 
Old 02-06-2010, 02:57 PM Re: USB enclosure MySQL data dump
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Ok, in the order:
Quote:
Am I looking at the sql data or physical files such as html, tpl, and php?
Yes, The database is not visible as is on the hard disk.
What you see are the directories present on the hard disk
Quote:
If it's the physical files such as html, tpl, and php how do I see the sql data?
I'm not sure of what you want to do?
Do you need to backup your currently running db to the hard disk, or to restore datas from the hard disk to your system ?

If you try to restore the datas:
Mysql is a server program, and you access it through a bridge, either the cli "mysql" application or any management applications that exists, or via a programming language, via a driver.

To access the mysql datas that are on that enclosure, you cannot use the mysqldump, mysql or mysqlrestore command, because those will only talk to the currently running mysql instance, not the one that have been dumped on the hard disk.

Your screenshot is so dark that even by pushing my monitor at the brightest, I cannot read the directories name, so it's hard to say what it exactly is.

But if your host did his job correctly, then you should have a ".sql" file in your host directory, that would be the result of a mysqldump.

Mysqldump is just a program that scripts the content of a database in a file.
The table structures and data rows are extracted from the db, and written as sql command in the file.
Then, you can replay them on another server to restore the state of the database.


If you want to backup your currently running db:
This is easy...
You already have the command: mysqldump.
As I explained for the restore part, mysqldump create a backup by scripting the state of your database in a file that can be replayed after.

To do that backup, just run the command you wrote in the first post.
It's the "> FILE.sql" part that matters here.

Mysqldump alone prints the command to the screen.
This ">" in unix means "redirect to".
So, "mysqldump > FILE.sql" means "run mysqldump and redirect everything that is printed to the screen to FILE.sql"
And your FILE.sql will be created at the same place you ran that command.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 02-06-2010, 05:27 PM Re: USB enclosure MySQL data dump
bbrian017's Avatar
Super Talker

Posts: 110
Trades: 0
I need to take the databases from the USB enclosure and export them all into my newly created database so I can restore them on my new server.

How do I export the sql databases from the USB enclosure?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


Last edited by bbrian017; 02-06-2010 at 05:31 PM..
bbrian017 is offline
Reply With Quote
View Public Profile Visit bbrian017's homepage!
 
Old 02-06-2010, 06:06 PM Re: USB enclosure MySQL data dump
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Well, you have to locate the place where the mysql installation located the files previously.
For exemple, on my linux box, it's on /var/lib/mysql
A database named "test" will be present in the form of a folder named "test".

Now, I never did this, but if the new server is the same version than the old one, you might be able to copy the folder from the old directory to the new.

I just tested it live on my box, and it worked.
I copied a database/directory "test" to "test2", and restarted the mysql service, and I had a "test2" database available through the mysql client.

Now, if the disk in your enclosure is located at /home/ and if the mysql files are at the same place than on my server, you should found them on /home/var/lib/mysql

You can try to look for files named *.MYD, *.MYI or *.frm. The case is important !
Try to locate them with this command:
Code:
find -iname '*.MYD' /home/
to look for every files with a MYD extension.

Then, try to locate where your actual mysql database files are located.
Adapt the "find" command up there to locate them, if needed.

Once this is done, copy the directories ( "cp -a" to keep the permissions) from the enclosure to the working server location, but be sure that you don't have any existing database with the same name that exists.
You could corrupt the working database by overwriting a file that is in use.

Then restart the mysql server ("/etc/init.d/mysql restart" on my box) and you should be ready to roll.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 02-06-2010, 09:32 PM Re: USB enclosure MySQL data dump
bbrian017's Avatar
Super Talker

Posts: 110
Trades: 0
What happens if the /var/lib/mysql doesn't exist?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

bbrian017 is offline
Reply With Quote
View Public Profile Visit bbrian017's homepage!
 
Old 02-07-2010, 06:07 AM Re: USB enclosure MySQL data dump
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
that means they are in another place. You have to find them.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to USB enclosure MySQL data dump
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.64908 seconds with 13 queries