Databases

Databases (47)

b2ap3_thumbnail_iStock_000018560014XSmall.jpgSometimes databases are lost. Human factor and stuff like that… If you didn’t backup (you better do) or the backup is old, don’t despair, there is still a chance of recovering the information which has been lost.

Starting from 4.1.3 version, MySQL writes all queries that change the data into a binary log. But this operation can be truned off by default. For example, after installation my home page didn’t have binary logs. I have turned it on by uncommenting the line log_bin = /var/log/mysql/mysql-bin.log in configuration file (my.cnf). Although server’s binary log was on from the very beginning and the parameter in the settings looks different: log-bin = mysql-bin. Logging is also on if MySQL was launched with the key --log-bin[=file_name].

b2ap3_thumbnail_iStock_000022037685XSmall.jpg

It began one beautiful morningwhen the kernel killed the demon mysqld and mysql_safe had automatically restarted it. All fine and dandy, but the database tables were used by MyISAM. Eventually, I had to resort to myisamcheck but that is another story. During the repairing and checking indices one table got corrupted and it was decided to recover from backups. Just imagine what a relief it was to find out that we do backups daily!

b2ap3_thumbnail_iStock_000005664283XSmall.jpg

It happens that MySQL data files get corrupted and require recovery. The easiest way of checking the integrity of table is by running the following command:


CHECK TABLE messages;

That phrase is going to check for errors in the messages table. If the output data look like in the picture below, it means that the table is fine and no recovery is required.

b2ap3_thumbnail_MySQL.jpg

In some cases the Msg_text columns might display error messages. In the event of that you need to run REPAIR TABLE, and MySQL will try to fix the problem.

b2ap3_thumbnail_iStock_000021573240XSmall_20130909-064451_1.jpgMethod No 1
Create backups ibdata1,ib_logfile0 и ib_logfile1 before starting the data recovery.
Also create backups of your folder containing .frm files.

Database recovery from the existing backup.
First of all transfer all backups to another MySQL server, recover data in MySQL data directory.

Grant relevant rights and permissions and designate the owner of files of database files (usually mysql).
Determine the size of Innodb logfiles by running the ls -l command.
You will see the following:
-rw-rw---- 1 mysql mysql 5242880 Jun 25 11:30 ib_logfile0
-rw-rw---- 1 mysql mysql 5242880 Jun 25 11:30 ib_logfile1

/usr/sbin/mysqld --innodb_log_file_size=5242880 --innodb_force_recovery=6

b2ap3_thumbnail_iStock_000024176180XSmall.jpgMySQL is a famous database management system (DBMS), widely used in combination with PHP.

Database is a structured collection of data. The data may range from a simple list of items to be purchased to a catalog of exhibit items in the picture gallery or to a large amount of information in the corporate network. To record, retrieve and process data stored in the computer database, one needs such software as MySQL. Since computers have no difficulties processing large amount of data, database management plays a key role in calculations. Database management may be provided by a separate utility or by a code integrated into other applications.

MySQL is a relational database management system. In relational database, data are not just piled up but stored in separate tables. This approach provides higher speed and flexibility. Tables are connected to each other with special relations. Thus query execution benefits from simultaneous processing of data stored in various tables. SQL as a part of MySQL is a language of structured queries and a widely used standard language applied to access database.

Get Help Now

Thank you for contacting us.
Your Private Investigator will call you shortly.