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