默认的安装是不带有前缀的,有的时候我们很多数据库想安装在一个数据库表中,那么就要通过前缀进行区分,然后我们可以一个数据库安装很多magento网站,下面是magento安装完毕后,修改表的前缀的方法:
1.新建一个文件prifix.php
2.加入内容:
<?php $database_host = "localhost"; $database_user = "root"; $database_password = "root"; $magento_database = "magento2"; $table_prefix = "dwz_";$db = mysql_connect($database_host, $database_user, $database_password); mysql_select_db($magento_database); $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); }~~~~~~~~~~~~~~~~~~~~~~~·
说明:填写完成后运行代码
$database_host = "localhost"; $database_user = "root";//数据库用户 $database_password = "";//数据库的密码 $magento_database = "magento2";//数据库的名字 $table_prefix = "dwz_"; //表的前缀
然后到文件app/etc/local.xml中
<table_prefix><![CDATA[]]></table_prefix>改为
<table_prefix><![CDATA[dwz_]]></table_prefix>
OK,搞定!完毕!table表的前缀批量修改完成,您可以一个数据库中安装很多系统了!