I ran this php script to change the Magento DB table prefix
// mege_rename_table_prefix.php //New Prefix Name $table_prefix = "test_"; //Magento Database Backup PHP error_reporting(E_ALL ^ E_NOTICE); ini_set('display_errors', 1); ini_set('memory_limit', '1512M'); // Get Magento Application require_once 'app/Mage.php'; Mage::app(); // Mage::app('default'); //Mage::app('main'); // get Magento config $config = Mage::getConfig()->getResourceConnectionConfig("default_setup"); $dbinfo = array( "host" => $config->host, "user" => $config->username, "pass" => $config->password, "dbname" => $config->dbname ); // Database Config $db_host = $dbinfo["host"]; $db_user = $dbinfo["user"]; $db_pass = $dbinfo["pass"]; $db_name = $dbinfo["dbname"]; //conect db $db = mysql_connect($db_host, $db_user, $db_pass); mysql_select_db($db_name); $query = "SHOW TABLES"; $result = mysql_query($query) or die('Err'); while($row = mysql_fetch_array($result)) { $old_table = $row[0]; if(preg_match('/'.$table_prefix.'/', $old_table)) { echo "Table $old_table already done<br/>\n"; continue; } $new_table = $table_prefix.$old_table; echo "Renaming $old_table to $new_table<br/>\n"; $query = "RENAME TABLE `$old_table` TO `$new_table`"; mysql_query($query); }
source share