InnoDB Database Batch Conversion table engine is MyISAM

Source: Internet
Author: User

12345678910111213141516171819202122 <?php//Connect to database$host=' localhost '; $user=' Mysql_username '; //Manage account $passwd=' Mysql_password '; //password $db=' Wordpressdb '; //Database name $link= mysql_connect($host,$user,$passwd); if (! $link) { die(' Could not connect: '. Mysql_error() ); } mysql_select_db ( $ Db, $link or die ( ' can\ ' t use ' .< Span class= "crayon-h" > $db . mysql_error () Span class= "Crayon-sy", $result=mysql_query("Show Tables") or Die ( mysql_error ());while($row=mysql_fetch_row($result)){ #echo $row [0];#var_dump ($row);echo "$row [0] \ n"; mysql_query("ALTER TABLE $row [0] type= ' MYISAM '") or Die (mysql_ Error()); }#var_dump ($result);mysql_close($link); ?>


MySQL from 5.5 After the default engine is INNODB,INNODB than MyISAM much better, but after all, huge bloated, so before is the default MyISAM, hardware and software resources are increasingly rich, InnoDB is valued.

If it is an old database, using the MyISAM engine, you can switch to the InnoDB engine with a smooth transition. MySQL provides a conversion script (in fact, the default is to give you to turn the innodb–> MyISAM), can be exchanged between the two engines, the use is very simple, you can see the help, here is an example of a newly converted table:

1234 mysql_convert_table_format yourdb --User=root --Password=' YOUPW ' -F --Socket= '/var/run/mysqld/mysqld.sock ' Yourdb is the name of the database to convert YOURPW is the root password The socket can be in my. The cnf file is found.

Precautions:

1, MySQl 5.5, mysql_convert_table_format default is to convert InnoDB to MyISAM, if you want to turn, with –engine= InnoDB is not (inexplicable is not), to directly modify/usr/bin /mysql_convert_table_format script, will be inside $opt _engine= "MYISAM";  Change into $opt _engine= "INNODB"; And then you run it.

2, do not arbitrarily convert MySQL own database (MySQL), this database must be MyISAM engine.

InnoDB Database Batch Conversion table engine is MyISAM

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.