Posts

Showing posts from May, 2024

Restore Database from .idb & .frm files in MySQL

Image
  Prerequisites:                Backup of .ibd and .frm files: Ensure you have all the relevant .ibd (InnoDB data files) and .frm (table definition files) for the tables you want to restore. MySQL Server: Ensure you have a running instance of MySQL server where you want to restore the database. Step 1: Stop Current Running MySQL Service Step 2: Copy ibdata1, ib_logfile0 and ib_logfile1 files from Old Mysql forlder Which is exist (C:\ProgramData\MySQL\MySQL Server x.x\Data).   Step 3: Copy your Database Folder which you want to restore and paste into your current mysql instance data folder.   Step 4: Change the configuration of my.ini file Add  –innodb_force_recovery=6 after the [mysqld] (please search inside my.ini file [mysqld]). Step 5: S tart the mysql service. Step 6: After recovering the database please remove the line innodb_force_recovery=6 from my.ini configuration and restart again mysql service.  

Reset the MySQL root Password

  sudo /etc/init.d/mysql stop This command stops the running MySQL service. If you try to start MySQL in mysqld_safe mode without stopping the regular service, you may encounter conflicts. mkdir /var/run/mysqld This command creates the directory used by MySQL for its socket file and other runtime data. If this directory doesn't exist, MySQL might fail to start. sudo chown mysql /var/run/mysqld/ This command sets the ownership of /var/run/mysqld to the mysql user. This is necessary to allow MySQL to create and use files within this directory. sudo mysqld_safe --skip-grant-tables & This command starts MySQL in "safe" mode without enforcing user authentication or privileges. The & at the end runs it in the background, allowing you to continue using the terminal. sudo mysql --user=root mysql Since --skip-grant-tables is enabled, no password is required. This command connects to MySQL as root and selects the mysql database, which contains user infor