Explore information related to innodb

Recover orphan innodb database from ibd file - How to perform this task

This article covers how to recover the orphan InnoDB database from the ibd file. 


Orphan InnoDB database incident mostly happened when:

1 – user accidentally remove ibdata1 file. (mostly in /var/lib/mysql/ibdata1).

2 – ibdata file courrupted.


To Recover Orphaned InnoDB Tables:

1. Restart the MySQL service to recreate ibdata1, then take a backup of your database folder.

2. Login to MySQL.

3. Create a dummy database with the same name. Then, create a dummy table with the same name as the corrupted one (don’t mind the table structure for now).

4. Stop the MySQL service, copy the .frm file from the backup you took to replace the .frm file.

5. Start MySQL and have a look at the structure of your table - it should now be in place! However, don’t get too happy yet.

6. Issue a SHOW CREATE TABLE statement and copy its contents, then create the table with them.

7. Stop MySQL, copy the .ibd file from the backup directory to /var/lib/database_name and replace the existing .ibd file from the dummy table.

8. Now it’s time for Percona’s tools to shine - download and install the Percona Data Recovery Tool for InnoDB , then run the following (here -o represents the full location of your ibdata1 file, -f represents the full location of your .ibd file, -d represents the database name and -t represents your table name):

ibdconnect -o /var/lib/mysql/ibdata1 -f /var/lib/mysql/database_name/table_name.ibd -d database_name -t table_name

9. Now, run a checksum check against InnoDB - make sure you get no error messages (you might need to run this tool several times):

innochecksum /var/lib/mysql/ibdata1

10. Finally, you should be good to go - simply start MySQL.

Read More



MySQL crash – Causes Recovery and Prevention methods

This article covers methods to fix and prevent MySQL downtime. Basically, many issues such as resource limits, #database table errors, file system errors, and so on, can lead to a MySQL crash.


To fix MySQL errors in cPanel?

You can also restart the MySQL service from WHM.

1. Login to WHM.

2. Navigate to Restart Services.

3. Now you can restart the MySQL service by clicking the icon “SQL Server(MySQL)”.


To use mysqlcheck, follow these steps:

1. As the root user, type the following command: cd /var/lib/mysql.

2. Replace the database with the name of the database that you want to check.

3. Mysqlcheck checks the specified database and tables.


How do I know if MySQL is running?

We check the status with the service mysql status command. We use the mysqladmin tool to check if MySQL server is running. 

The -u option specifies the user which pings the server. 

The -p option is a password for the user.


What does repair table do MySQL?

REPAIR TABLE repairs a possibly corrupted table, for certain storage engines only. 

This statement requires SELECT and INSERT privileges for the table. Although normally you should never have to run REPAIR TABLE , if disaster strikes, this statement is very likely to get back all your data from a MyISAM table.


What causes MySQL #tables to crash?

The major cause of the database corruption is the lack of free disk space on the server.

Other possible causes of MySQL table crashes include operating system problems, power failures, hardware issues, unexpected MySQL server termination, data corruption due to external programs, and so on.


To access your #MySQL database in Linux, please follow these steps:

1. Log into your Linux web server via Secure Shell.

2. Open the MySQL client program on the server in the /usr/bin directory.

3. Type in the following syntax to access your database: $ mysql -h {hostname} -u username -p {databasename} Password: {your password}

Read More



InnoDB vs MyISAM Performance

This article will guide you on the performance of InnoDB and MyISAM. MyISAM will out-perform InnoDB on large #tables that require vastly more read activity versus write activity. MyISAM's readabilities outshine InnoDB because locking the entire table is quicker than figuring out which rows are locked in the table.

InnoDB is better option while you are dealing with larger #database because it supports transactions, volume while MyISAM is suitable for small project. 

InnoDB and MYISAM , are storage engines for MySQL . 


InnoDB and #MYISAM differ on their locking implementation: 

i. #InnoDB locks the particular row in the table, and MyISAM locks the entire MySQL table.

ii. As InnoDB supports row-level locking which means inserting and updating is much faster as compared with MyISAM.


Which storage engine is best in #MySQL:

1. InnoDB: The default option in MySQL 5.7, InnoDB is a robust storage engine that offers:

2. MyISAM: The functionality that sets MyISAM apart is its capability for:

3. NDB (or NDBCLUSTER): If a clustered environment is where your database will be working, NDB is the storage engine of choice.

Read More