MySql stops unexpectedly - mysql

MySql stops unexpectedly
Here is a copy of Error log:
2019-07-03 13:27:50 0 [ERROR] InnoDB: Your database may be corrupt or
you may have copied the InnoDB tablespace but not the InnoDB log
files. Please refer to
https://mariadb.com/kb/en/library/innodb-recovery-modes/ for
information about forcing recovery.
2019-07-03 13:27:50 0 [Note]
InnoDB: 128 out of 128 rollback segments are active.
2019-07-03 13:27:50 0 [ERROR] InnoDB: Page [page id: space=0, page number=305]
log sequence number 2834539 is in the future! Current system log
sequence number 1604011.
2019-07-03 13:27:50 0 [ERROR] InnoDB: Your
database may be corrupt or you may have copied the InnoDB tablespace
but not the InnoDB log files. Please refer to
https://mariadb.com/kb/en/library/innodb-recovery-modes/ for
information about forcing recovery.
2019-07-03 13:27:50 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2019-07-03 13:27:50 0 [Note] InnoDB: Setting file 'C:\xampp\mysql\data\ibtmp1'
size to 12 MB. Physically writing the file full; Please wait ...
2019-07-03 13:27:50 0 [Note] InnoDB: File 'C:\xampp\mysql\data\ibtmp1'
size is now 12 MB.
2019-07-03 13:27:50 0 [Note] InnoDB: Waiting for purge to start
2019-07-03 13:27:50 0 [Note] InnoDB: 10.3.16 started;
log sequence number 1604002; transaction id 1432
2019-07-03 13:27:50 0 [Note] InnoDB: Loading buffer pool(s) from
C:\xampp\mysql\data\ib_buffer_pool
2019-07-03 13:27:50 0 [ERROR] InnoDB: Page [page id: space=0, page number=9] log sequence number
2841120 is in the future! Current system log sequence number 1604011.
2019-07-03 13:27:50 0 [ERROR] InnoDB: Your database may be corrupt or
you may have copied the InnoDB tablespace but not the InnoDB log
files. Please refer to
https://mariadb.com/kb/en/library/innodb-recovery-modes/ for
information about forcing recovery.
2019-07-03 13:27:50 0 [ERROR] InnoDB: Page [page id: space=0, page number=243] log sequence number
2082633 is in the future! Current system log sequence number 1604011.
2019-07-03 13:27:50 0 [ERROR] InnoDB: Your database may be corrupt or
you may have copied the InnoDB tablespace but not the InnoDB log
files. Please refer to
https://mariadb.com/kb/en/library/innodb-recovery-modes/ for
information about forcing recovery.
2019-07-03 13:27:50 0 [ERROR] InnoDB: Page [page id: space=1, page number=0] log sequence number
1608629 is in the future! Current system log sequence number 1604011.
2019-07-03 13:27:50 0 [Note] Plugin 'FEEDBACK' is disabled.
2019-07-03 13:27:50 0 [ERROR] InnoDB: Your database may be corrupt or you may
have copied the InnoDB tablespace but not the InnoDB log files. Please
refer to https://mariadb.com/kb/en/library/innodb-recovery-modes/ for
information about forcing recovery.
2019-07-03 13:27:50 0 [ERROR] InnoDB: Page [page id: space=1, page number=1] log sequence number
1604111 is in the future! Current system log sequence number 1604011.
2019-07-03 13:27:50 0 [ERROR] InnoDB: Your database may be corrupt or
you may have copied the InnoDB tablespace but not the InnoDB log
files. Please refer to
https://mariadb.com/kb/en/library/innodb-recovery-modes/ for
information about forcing recovery.
2019-07-03 13:27:50 0 [Note] Server socket created on IP: '::'.
2019-07-03 13:27:50 0 [ERROR] InnoDB: Page [page
What can I do to get my database up and running again?
All help is greatly appreciated!

I have faced the same problem. I just followed the below steps
Step 1: Moved(cut/paste) all the files in C:\xampp\mysql\data to desired backup location.
Step 2: After that copied all the files from C:\xampp\mysql\backup to C:\xampp\mysql\data
Step 3: Restarted mysql and checked the phpmyadmin url, it worked.
Step 4: After that stopped mysql and copied ibdata1 file from backup location to C:\xampp\mysql\data
Step 5: Restarted mysql
Step 6: After that copied all database folders and checked all the tables, It worked.

I also faced this issue and searched a lot only one solution worked for me.
Just copy all files from C:\xampp\mysql\backup to C:\xampp\mysql\data
Make sure to take backup of your data folder to avoid any further problems.
If you see any error related to table engine then you can copy file ibdata1 from your backup data folder to current data folder

Seems that there is corruption in MySQL log and/or data files, one way to workaround this problem is to start MySQL in recovery mode.
From my.ini in windows (or my.cnf in Linux) add the following line:
innodb_force_recovery=1 under [mysqld] section then re-start MySQL service.
If the problem persisted, mysqlcheck can help, move to the folder where MySQL binaries exist in your machine, and in Command Line execute ./mysqlcheck.exe --all-databases this will list tables that are corrupted
Reference:
https://dev.mysql.com/doc/refman/8.0/en/forcing-innodb-recovery.html

Just Unintall XAMPP and the reinstall it , it will resolve all the issue , but make sure to have the backup of your MYSQL database.

If your backup folder doesn't include your latest DB changes and you are stuck with collation of in use, then do this instead:
Install another XAMPP instance in new folder;
Copy the single folder of: [old_xampp]/mysql/data/[table_name]/ into [new_xampp]/mysql/data/;
Copy a file from: [old_xampp]/mysql/data/ibdata1 to: [new_xampp]/mysql/data/ibdata1 and replace it;
Stop old XAMPP;
Run new XAMPP.
DONE!
All your new table entries should be brought back.

Related

Why won't mySQL start?

I've tried many things said on the internet, also tried to fix it myself, but I don't have any clue, what I could do next. I can't Reinstall it, because there is important data on it.
The log:
htts://mariadb.com/kb/en/library/innodb-recovery-modes/ for information about forcing recovery.
2022-12-31 0:32:28 2 [ERROR] InnoDB: Page [page id: space=24, page number=1] log sequence number 300669 is in the future! Current system log sequence number 300459.
2022-12-31 0:32:28 2 [ERROR] InnoDB: Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB log files. Please refer to htts://mariadb.com/kb/en/library/innodb-recovery-modes/ for information about forcing recovery.
2022-12-31 0:32:28 0 [Note] InnoDB: 10.4.27 started; log sequence number 300450; transaction id 214
2022-12-31 0:32:28 0 [Note] InnoDB: Loading buffer pool(s) from C:\xampp\mysql\data\ib_buffer_pool
2022-12-31 0:32:28 0 [Note] Plugin 'FEEDBACK' is disabled.
2022-12-31 0:32:28 0 [Note] Server socket created on IP: '::'.
I've tried updateing the config.
I've tried booting without password.
There are currently two methods:
Modify the value of innodb_force_recovery in the parameter file, and then start the database. If it succeeds, you need to export the data, then recreate the database, and then import the data. If not, refer to the second point.
There are some tools, some paid and some free. You can retrieve the data through the ibdata file, and rebuild the database after retrieval.
Of course it is very important not to delete the data files

Xampp MySql Error: MySQL shutdown unexpectedly

my Xampp MySql won't start. Elsewhere in this forum was has been advised to change the file name C:\xampp\mysql\data\ibdata1 to ibdata1.bak and turn off the Xampp. But it did not help. Is there a way to fix this?
2020-09-17 17:19:47 2 [ERROR] InnoDB: Page [page id: space=33, page number=1] log sequence number 402782 is in the future! Current system log sequence number 47064.
2020-09-17 17:19:47 2 [ERROR] InnoDB: Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB log files. Please refer to https://mariadb.com/kb/en/library/innodb-recovery-modes/ for information about forcing recovery.
2020-09-17 17:19:47 0 [Note] InnoDB: 10.4.11 started; log sequence number 47055; transaction id 347965
2020-09-17 17:19:47 0 [Note] InnoDB: Loading buffer pool(s) from C:\xampp\mysql\data\ib_buffer_pool
2020-09-17 17:19:47 0 [Note] Plugin 'FEEDBACK' is disabled.
2020-09-17 17:19:47 0 [ERROR] InnoDB: Page [page id: space=0, page number=243] log sequence number 336525986 is in the future! Current system log sequence number 47064.
2020-09-17 17:19:47 0 [ERROR] InnoDB: Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB log files. Please refer to https://mariadb.com/kb/en/library/innodb-recovery-modes/ for information about forcing recovery.
2020-09-17 17:19:47 0 [ERROR] InnoDB: Page [page id: space=0, page number=309] log sequence number 332378035 is in the future! Current system log sequence number 47064.
2020-09-17 17:19:47 0 [Note] Server socket created on IP: '::'.
2020-09-17 17:19:47 0 [ERROR] InnoDB: Your database may be corrupt or you may have copied the InnoDB tablespac
Your files (maybe log files) and the time of your PC have conflict!
log sequence number 402782 is in the future!
check your PC time and sync it with real time!
remove all files which have a date-time more than your PC date-time (if possible! if not, create a new one in a proper date). For example your PC date is 2019-xx-xx and your files is 2020-xx-xx.

MAMP Pro can't start MySQL

I had to force a shutdown when my computer froze, and MAMP has been unable to start MySql since then. I have tried deleting the log files from MAMP/DB/mysql and restarting MAMP, but it hasn't worked. I also tried entering sudo killall -9 mysqld in the terminal, to no avail.
Here is the error log from MAMP:
2017-05-12 16:05:49 4691 [Note] InnoDB: The log sequence numbers 730255276 and 730255276 in ibdata files do not match the log sequence number 730624549 in the ib_logfiles!2017-05-12 16:05:49 4691 [Note] InnoDB: Database was not shutdown normally!
2017-05-12 16:05:49 4691 [Note] InnoDB: Starting crash recovery.
2017-05-12 16:05:49 4691 [Note] InnoDB: Reading tablespace information from the .ibd files...
2017-05-12 16:05:50 4691 [ERROR] InnoDB: Attempted to open a previously opened tablespace. Previous tablespace mysql/slave_worker_info uses space ID: 5 at filepath: ./mysql/slave_worker_info.ibd. Cannot open tablespace wordpress#0020test#0020site/wp_term_taxonomy which uses space ID: 5 at filepath: ./wordpress#0020test#0020site/wp_term_taxonomy.ibd
2017-05-12 16:05:50 7fff7303b000 InnoDB: Operating system error number 2 in a file operation.
InnoDB: The error means the system cannot find the path specified.
InnoDB: If you are installing InnoDB, remember that you must create
InnoDB: directories yourself, InnoDB does not create them.
InnoDB: Error: could not open single-table tablespace file ./wordpress#0020test#0020site/wp_term_taxonomy.ibd
InnoDB: We do not continue the crash recovery, because the table may become
InnoDB: corrupt if we cannot apply the log records in the InnoDB log to it.
InnoDB: To fix the problem and start mysqld:
InnoDB: 1) If there is a permission problem in the file and mysqld cannot
InnoDB: open the file, you should modify the permissions.
InnoDB: 2) If the table is not needed, or you can restore it from a backup,
InnoDB: then you can remove the .ibd file, and InnoDB will do a normal
InnoDB: crash recovery and ignore that table.
InnoDB: 3) If the file system or the disk is broken, and you cannot remove
InnoDB: the .ibd file, you can set innodb_force_recovery > 0 in my.cnf
InnoDB: and force InnoDB to continue crash recovery here.
170512 16:05:50 mysqld_safe mysqld from pid file /Applications/MAMP/tmp/mysql/mysql.pid ended
Any ideas?
I've just had the same problem with MAMP.
To solve the problem, i was forced to delete the file that causes the error located in "Applications/MAMP/db/mysql56/bib" and then recreate the TABLE/BASE afterwards.
I hope that would be helpful.

mysql not working , it is not starting

here is a bit of the error log .
160422 10:45:00 [Note] InnoDB: The log sequence numbers 1665244 and 1665244 in ibdata files do not match the log sequence number 15857945 in the ib_logfiles!
160422 10:45:00 [Note] InnoDB: Database was not shutdown normally!
160422 10:45:00 [Note] InnoDB: Starting crash recovery.
160422 10:45:00 [Note] InnoDB: Reading tablespace information from the .ibd files...
160422 10:45:00 [Note] InnoDB: Restoring possible half-written data pages
160422 10:45:00 [Note] InnoDB: from the doublewrite buffer...
160422 10:45:00 [Note] InnoDB: 128 rollback segment(s) are active.
160422 10:45:00 [Note] InnoDB: Percona XtraDB (http://www.percona.com) 5.6.22-72.0 started; log sequence number 15857945
160422 10:45:00 [Note] InnoDB: !!! innodb_force_recovery is set to 2 !!!
160422 10:45:00 [Note] Plugin 'FEEDBACK' is disabled.
160422 10:45:00 [Note] Server socket created on IP: '::'.
160422 10:45:00 [ERROR] mysqld.exe: Table '.\mysql\db' is marked as crashed and last (automatic?) repair failed
160422 10:45:00 [ERROR] Fatal error: Can't open and lock privilege tables: Table '.\mysql\db' is marked as crashed and last (automatic?) repair failed
plz somebody help , i have one important database ,whose backup i have not made , i posted this question earlier ,but didnt got the answer ...this started when i was trying to access phpmyadmin , from then on mysql is not starting.
I see two potential ways out of it.
For the following:
Table '.\mysql\db' is marked as crashed and last (automatic?) repair failed
You can use mysqlcheck to repair it, if it is a MyISAM DB. Else try the InnoDB force recovery option if it is InnoDB database. You can start your DB with InnoDB force recovery and take a DB dump from it, to restore it on a fresh MySQL install.
In future, try enabling innodb_file_per_table option.
Now, second option. Even though the first one looks most likely.
The log sequence numbers 1665244 and 1665244 in ibdata files do not match the log sequence number 15857945 in the ib_logfiles!
If the first method doesnt work, give this a try. It looks like the ib_logfiles are corrupt, I faced this issue before and used the following steps to get my DB up and working:
Take a full backup of your mysql datadir in another directory.
Make sure mysql service is stopped.
remove the ib_logfile1 and ib_logfile2
Start the MySQL service
Hope it helps
Rishav, innodb_force_recovery doesn't recover anything. It is a mode you start your mysql with. Once it starts, you should be able to take a dump. Following should be the steps:
Steps to get it back up.
1. Stop mysqld.
2. Backup /var/lib/mysql/ib*
3. Add the following line into /etc/my.cnf
innodb_force_recovery = 4
4. Restart mysqld.
5. Dump your DB using mysqldump to a dump.sql file.
6. Drop all databases which need recovery.
7. Stop mysqld.
8. Remove /var/lib/mysql/ib*
9. Comment out innodb_force_recovery in /etc/my.cnf
10. Restart mysqld. Look at mysql error log. By default it should be /var/lib/mysql/server/hostname.com.err to see how it creates new ib* files. (Although, I recommend a fresh setup here)
11. Restore databases from the dump:mysql < dump.sql

recover mysql database from ibdata1

I have a client who appears to have lost all of their mysql databases from their local machine. They are on a Mac, which I am somewhat unfamiliar with and I am on Ubuntu. There were no .MYD or .MYI files in the database folder, only .frm ones. I had them zip up the mysql and sight folders (with sight being the database we need), and the ibdata1, ib_logfile0, and ib_logfile1 files. I created a second folder for mysql, /var/lib/mysql2, and moved the files and folders into there. I chowned the new folder and files to mysql:mysql, edited /etc/mysql/my.cnf to point to the new folder, edited /etc/apparmor.d/usr.sbin.mysqld, and then restarted apparmor and mysql. However, I am getting the following errors in the mysql error log:
130308 17:38:16 [Note] Plugin 'FEDERATED' is disabled.
130308 17:38:16 InnoDB: Initializing buffer pool, size = 8.0M
130308 17:38:16 InnoDB: Completed initialization of buffer pool
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
130308 17:38:16 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
130308 17:38:16 InnoDB: Error: space id and page n:o stored in the page
InnoDB: read in are 0:589824, should be 0:7!
130308 17:38:16 InnoDB: Error: page 589824 log sequence number 786432 0
InnoDB: is in the future! Current system log sequence number 0 63932940.
InnoDB: Your database may be corrupt or you may have copied the InnoDB
InnoDB: tablespace but not the InnoDB log files. See
InnoDB: http://dev.mysql.com/doc/refman/5.1/en/forcing-innodb-recovery.html
InnoDB: for more information.
InnoDB: Database page corruption on disk or a failed
InnoDB: file read of page 7.
InnoDB: You may have to recover from a backup.
130308 17:38:16 InnoDB: Page dump in ascii and hex (16384 bytes):
len 16384; hex 0008000000090000000a0000000b0000000c00000000000000000000000202720000 (snipped because this goes on for a while)
Tg 9 <o q E i F / D ;InnoDB: End of page dump
130308 17:38:16 InnoDB: Page checksum 4146777650, prior-to-4.0.14-form checksum 1800374066
InnoDB: stored checksum 524288, prior-to-4.0.14-form stored checksum 0
InnoDB: Page lsn 786432 0, low 4 bytes of lsn at page end 0
InnoDB: Page number (if stored to page already) 589824,
InnoDB: space id (if created with >= MySQL-4.1.1 and stored already) 0
InnoDB: Page may be a freshly allocated page
InnoDB: Database page corruption on disk or a failed
InnoDB: file read of page 7.
InnoDB: You may have to recover from a backup.
InnoDB: It is also possible that your operating
InnoDB: system has corrupted its own file cache
InnoDB: and rebooting your computer removes the
InnoDB: error.
InnoDB: If the corrupt page is an index page
InnoDB: you can also try to fix the corruption
InnoDB: by dumping, dropping, and reimporting
InnoDB: the corrupt table. You can use CHECK
InnoDB: TABLE to scan your table for corruption.
InnoDB: See also http://dev.mysql.com/doc/refman/5.1/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
InnoDB: Ending processing because of a corrupt database page.
I have tried adding innodb_force_recovery = 4 to the my.cnf file, which generates a whole slew of different errors:
130308 17:48:30 [Note] Plugin 'FEDERATED' is disabled.
130308 17:48:30 InnoDB: Initializing buffer pool, size = 8.0M
130308 17:48:30 InnoDB: Completed initialization of buffer pool
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
130308 17:48:30 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
130308 17:48:30 InnoDB: Error: space id and page n:o stored in the page
InnoDB: read in are 0:589824, should be 0:7!
130308 17:48:30 InnoDB: Error: page 589824 log sequence number 786432 0
InnoDB: is in the future! Current system log sequence number 0 63932940.
InnoDB: Your database may be corrupt or you may have copied the InnoDB
InnoDB: tablespace but not the InnoDB log files. See
InnoDB: http://dev.mysql.com/doc/refman/5.1/en/forcing-innodb-recovery.html
InnoDB: for more information.
InnoDB: Database page corruption on disk or a failed
InnoDB: file read of page 7.
InnoDB: You may have to recover from a backup.
and a whole bunch more, which I can supply if it helps. Any suggestions on what to try from here would be greatly appreciated, thanks.
Edit: I tried following the steps here, but was having issues getting mysql to run using the command line sequence he used:
http://blog.shiraj.com/2012/10/extract-data-from-mysql-ibdata1-data-file/
The following worked for my:
Set innodb_force_recovery = 1 in your my.cnf
Try and get your mysqld to restart. If not, repeat step #1 and increment
innodb_force_recovery by each until successful. Use the guide to help you understand what's happening each time you increment it: http://dev.mysql.com/doc/refman/5.0/en/forcing-innodb-recovery.html
Once mysqld is running, try and dump all your databases
mysqldump -u root -p --all-databases > /tmp/mysqldump-all.sql
If that isn't successful, you'll have to try it first on the database level
mysqldump -u root -p --databases db_name > mysqldump-db_name.sql
If that isn't successful, you'll have to try it on the table level
SELECT * FROM table_name INTO OUTFILE '/tmp/table_name.sql'
Once one of those is successful and either all your db's or all your tables are exported, stop the mysqld
Move your ib_logfile* > ib_logfile*.bak. These are typically in your mysql data directory.
If in the first step you incremented your innodb_force_recovery => 4, you need to set it below 4. As of 5.6.15, an innodb_force_recovery setting of 4 or greater places InnoDB in read-only mode.
Start the mysqld server
Import your exported databases or tables
mysql -u root -p < /tmp/mysqldump-all.sql
Incremented your innodb_force_recovery => 1
Restart the mysqld server
This is worked for me:
innodb_force_recovery => 2
Login into MySQL server using HeidiSQL and dump all database
Reinstall MySQL server and import all the database from dump file.