Jump to content

MYSQL database safe

TiCeVi

I had an raspberry pi running a server with MYSQL. The pi stoped functioning but I could safe the SD card. Is it possible to safe a sql file without starting a server?

Link to comment
Share on other sites

Link to post
Share on other sites

Do you mean "save"? instead of "safe"?

 

If so, then yes. If the data is still intact then it shouldnt be hard to grab.

~Judah

Link to comment
Share on other sites

Link to post
Share on other sites

"saving" the data depends on a number of factors. It should be possible, but it's also possible the tables are corrupt and require repair.

I can walk you through the repair if that's the case.

Anyways, you'll want to copy the ENTIRETY of /var/lib/mysql/ in order to have any chance of recovery.

--Neil Hanlon

Operations Engineer

Link to comment
Share on other sites

Link to post
Share on other sites

I guess no (or at least i guess it will be harder than just run a mysql server and dump the data from there).

 

the data actually stored in the /var/lib/mysql/[database] directory depends on your storage engine (most common one's are InnoDB and MyISAM), maybe there are tools available that can read these files.

at least every table gets (on my server) it's own file...

 

as said, the most easy way to recover your data would be to reinstall the pi, install mysql server and restore the /var/lib/mysql directory from your backup and restart the mysql server.

Link to comment
Share on other sites

Link to post
Share on other sites

On my Pi I use SQLite database files. I keep them on external storage since they get modified often, and it also makes it easier to manage backups in case of a system failure.

 

In future, you should use a program such as WinDiskImager to take images of your Pi's SD card on a regular basis - so if the Pi does fail and take the SD card with it - you'll be up and running on another one in seconds.

Speedtests

WiFi - 7ms, 22Mb down, 10Mb up

Ethernet - 6ms, 47.5Mb down, 9.7Mb up

 

Rigs

Spoiler

 Type            Desktop

 OS              Windows 10 Pro

 CPU             i5-4430S

 RAM             8GB CORSAIR XMS3 (2x4gb)

 Cooler          LC Power LC-CC-97 65W

 Motherboard     ASUS H81M-PLUS

 GPU             GeForce GTX 1060

 Storage         120GB Sandisk SSD (boot), 750GB Seagate 2.5" (storage), 500GB Seagate 2.5" SSHD (cache)

 

Spoiler

Type            Server

OS              Ubuntu 14.04 LTS

CPU             Core 2 Duo E6320

RAM             2GB Non-ECC

Motherboard     ASUS P5VD2-MX SE

Storage         RAID 1: 250GB WD Blue and Seagate Barracuda

Uses            Webserver, NAS, Mediaserver, Database Server

 

Quotes of Fame

On 8/27/2015 at 10:09 AM, Drixen said:

Linus is light years ahead a lot of other YouTubers, he isn't just an average YouTuber.. he's legitimately, legit.

On 10/11/2015 at 11:36 AM, Geralt said:

When something is worth doing, it's worth overdoing.

On 6/22/2016 at 10:05 AM, trag1c said:

It's completely blown out of proportion. Also if you're the least bit worried about data gathering then you should go live in a cave a 1000Km from the nearest establishment simply because every device and every entity gathers information these days. In the current era privacy is just fallacy and nothing more.

 

Link to comment
Share on other sites

Link to post
Share on other sites

Thanks for all the help. The sd is still functioning. And I found the directory but I can't copy it because of some rights the owner is 'RealtimeKit'

Link to comment
Share on other sites

Link to post
Share on other sites

On my Pi I use SQLite database files. I keep them on external storage since they get modified often, and it also makes it easier to manage backups in case of a system failure.

In future, you should use a program such as WinDiskImager to take images of your Pi's SD card on a regular basis - so if the Pi does fail and take the SD card with it - you'll be up and running on another one in seconds.

I have an image of the old pi but now with the pi b+ doesn't boot. With the old image

Link to comment
Share on other sites

Link to post
Share on other sites

You can use sudo to copy the directory.

--Neil Hanlon

Operations Engineer

Link to comment
Share on other sites

Link to post
Share on other sites

I guess no (or at least i guess it will be harder than just run a mysql server and dump the data from there).

the data actually stored in the /var/lib/mysql/[database] directory depends on your storage engine (most common one's are InnoDB and MyISAM), maybe there are tools available that can read these files.

at least every table gets (on my server) it's own file...

as said, the most easy way to recover your data would be to reinstall the pi, install mysql server and restore the /var/lib/mysql directory from your backup and restart the mysql server.

Innodb's logfiles aren't stored in the individual db folder, so he'd need the binary log from /var/lib/mysql

--Neil Hanlon

Operations Engineer

Link to comment
Share on other sites

Link to post
Share on other sites

Innodb's logfiles aren't stored in the individual db folder, so he'd need the binary log from /var/lib/mysql

That should be true, but i wasn't talking about any logfiles, but about these binary as you were talking about, too ;).

They might depend on the storage engine, but maybe not (it would at least make sense to me).

Link to comment
Share on other sites

Link to post
Share on other sites

You can use sudo to copy the directory.

Yeah already tried that but even in the terminal it says I couldn't enter
Link to comment
Share on other sites

Link to post
Share on other sites

I have an image of the old pi but now with the pi b+ doesn't boot. With the old image

 

Oh. You'll need to get your hands on an old Pi then do rpi-update to upgrade the kernel and 'firmware' to run on newer Pis. There might be ways to fix it without getting an old pi however, since the kernel & boot commands are on the windows-readable fat32 partition.

Speedtests

WiFi - 7ms, 22Mb down, 10Mb up

Ethernet - 6ms, 47.5Mb down, 9.7Mb up

 

Rigs

Spoiler

 Type            Desktop

 OS              Windows 10 Pro

 CPU             i5-4430S

 RAM             8GB CORSAIR XMS3 (2x4gb)

 Cooler          LC Power LC-CC-97 65W

 Motherboard     ASUS H81M-PLUS

 GPU             GeForce GTX 1060

 Storage         120GB Sandisk SSD (boot), 750GB Seagate 2.5" (storage), 500GB Seagate 2.5" SSHD (cache)

 

Spoiler

Type            Server

OS              Ubuntu 14.04 LTS

CPU             Core 2 Duo E6320

RAM             2GB Non-ECC

Motherboard     ASUS P5VD2-MX SE

Storage         RAID 1: 250GB WD Blue and Seagate Barracuda

Uses            Webserver, NAS, Mediaserver, Database Server

 

Quotes of Fame

On 8/27/2015 at 10:09 AM, Drixen said:

Linus is light years ahead a lot of other YouTubers, he isn't just an average YouTuber.. he's legitimately, legit.

On 10/11/2015 at 11:36 AM, Geralt said:

When something is worth doing, it's worth overdoing.

On 6/22/2016 at 10:05 AM, trag1c said:

It's completely blown out of proportion. Also if you're the least bit worried about data gathering then you should go live in a cave a 1000Km from the nearest establishment simply because every device and every entity gathers information these days. In the current era privacy is just fallacy and nothing more.

 

Link to comment
Share on other sites

Link to post
Share on other sites

That should be true, but i wasn't talking about any logfiles, but about these binary as you were talking about, too ;).

They might depend on the storage engine, but maybe not (it would at least make sense to me).

The binary log files are necessary to repair databases. If you delete the innodb logs the tablespaces are unrecoverable.

--Neil Hanlon

Operations Engineer

Link to comment
Share on other sites

Link to post
Share on other sites

You can use sudo to copy the directory.

i could now copy the mysql folder. what should i do now?

 

thanks for the help

Link to comment
Share on other sites

Link to post
Share on other sites

Well make sure you have a copy of it. Install mysql. Start mysql with that directory as the data directory (I think it's the -D option but I'm on mobile)

Then mysqldump the table, and import it into the main mysql instance.

--Neil Hanlon

Operations Engineer

Link to comment
Share on other sites

Link to post
Share on other sites

Great. I figured it out already. I also had to change some of the permission with the chown command. After this I could copy the database folder in to the new MYSQL and phpmyadmin setup on my Ubuntu system. Now I could export the table as .sql file and import on the Pi system.

Thanks for all the great advise and help[emoji2]

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×