The innodb storage engine modifies the table Shared space into a separate space

  • 2020-06-03 08:37:21
  • OfStack

1. Check whether the table space is Shared or separate under 1


mysql> show variables like '%per_table%';
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| innodb_file_per_table | OFF |
+-----------------------+-------+
1 row in set (0.00 sec)

If it's OFF, it's definitely not a stand-alone table space. If it is ON, it is not necessarily a separate table space. The most direct method is to look at the files on the hard disk, separate table space, each table corresponds to 1 space.
[/code]
[root@localhost tg]# ll
The total amount of 64
-- rw -- rw-- 1 mysql mysql 65 December 30 20:09 db
-rw-rw-- 1 mysql mysql 8658 December 30 23:17 gb
-rw-rw-- 1 mysql mysql 8658 December 30 23:19 qr
-rw-rw-- 1 mysql mysql 8658 December 30 23:19 qy
-rw-rw-- 1 mysql mysql 8658 December 30 23:19 tg
-rw-rw-- 1 mysql mysql 8658 December [/code]

tg is the name of a database, and everything in it is innodb. In this case, it's a Shared table space.

2, stopped mysql


/etc/init.d/mysqld stop

3. Modify the configuration file of ES63en.cnf


innodb-file-per-table=1

4. Back up the database using the innodb engine


mysqldump -u tg -p tg >/home/6fan/tg.sql;

5. Delete the database using innodb and log files


cd /var/lib/mysql // Database file location 
rm -f ib* // Delete logs and Spaces 
rm -rf tg // Delete use innodb Database folder for the engine 

I couldn't start the innodb engine without deleting the database folder using innodb. I checked the error log 1 time. The following


111231 20:54:44 InnoDB: Log file ./ib_logfile0 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile0 size to 512 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Progress in MB: 100 200 300 400 500
111231 20:54:50 InnoDB: Log file ./ib_logfile1 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile1 size to 512 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Progress in MB: 100 200 300 400 500
InnoDB: Cannot initialize created log files because
InnoDB: data files are corrupt, or new data files were
InnoDB: created when the database was started previous
InnoDB: time but the database was not shut down
InnoDB: normally after that.
111231 20:54:55 [ERROR] Plugin 'InnoDB' init function returned error.
111231 20:54:55 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
111231 20:54:55 [Note] Event Scheduler: Loaded 0 events

6, start mysql


/etc/init.d/mysqld start

7. Import database


mysql -u root -p < /home/6fan/tg.sql

8, under view 1, is converted


mysql> show variables like '%per_table%';
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| innodb_file_per_table | ON |
+-----------------------+-------+
1 row in set (0.00 sec)
// View the files in the database directory 
[root@localhost tg]# ll
 The total amount  544
-rw-rw----. 1 mysql mysql 65 12 month  31 22:48 db.opt
-rw-rw----. 1 mysql mysql 8658 12 month  31 22:49 gb.frm
-rw-rw----. 1 mysql mysql 98304 12 month  31 22:49 gb.ibd
-rw-rw----. 1 mysql mysql 8658 12 month  31 22:49 qr.frm
-rw-rw----. 1 mysql mysql 98304 12 month  31 22:49 qr.ibd
-rw-rw----. 1 mysql mysql 8658 12 month  31 22:49 qy.frm
-rw-rw----. 1 mysql mysql 98304 12 month  31 22:49 qy.ibd
-rw-rw----. 1 mysql mysql 8658 12 month  31 22:49 tg.frm
-rw-rw----. 1 mysql mysql 98304 12 month  31 22:49 tg.ibd
-rw-rw----. 1 mysql mysql 8658 12 month  31 22:49 xcy.frm
-rw-rw----. 1 mysql mysql 98304 12 month  31 22:49 xcy.ibd

As you can see, there should be 1.ibd file for each table, and the root Shared table space is different. It's completely configured at this point.


Related articles: