Welcome to the Linux community forum and interact with 2 million technical staff. We often encounter the problem of replacing or adding the database table prefix. Export the database, change it in batch in notepad, and then export it again, this is also a method, but it is not convenient. Through the following method, you can easily solve the problem. The Code is as follows .? Php $ dat
Welcome to the Linux community forum and interact with 2 million technical staff> we often encounter the problem of replacing or adding the database table prefix when entering the Forum. Export the database and change it in batches in notepad, this is also a method, but it is not convenient. The following method makes it easy to solve the problem. The Code is as follows. ? Php $ dat
Welcome to the Linux community forum and interact with 2 million technicians>
We often encounter the problem of replacing or adding the database table prefix. This is also a method, but it is not convenient enough. You can export the database, change it in batches in notepad, and then export it again.
The following method makes it easy to solve the problem. The Code is as follows.
$ Database = "databaseName ";
// Database Name
$ User = "root ";
// Database username
$ Pwd = "pwd ";
// Database Password
$ Replace = 'pre _';
// The prefix after replacement
$ Seach = 'pre1 _';
// The prefix to be replaced
$ Db = mysql_connect ("localhost", "$ user", "$ pwd") or die ("Database Connection Failed:". mysql_error ());
// Connect to the database
$ Tables = mysql_list_tables ("$ database ");
While ($ name = mysql_fetch_array ($ tables )){
$ Table = str_replace ($ seach, $ replace, $ name ['0']);
Mysql_query ("rename table $ name [0] to $ table ");
}
?>
If you want to add a prefix, you only need to change it a little bit.
$ Table = str_replace ($ seach, $ replace, $ name ['0']);
Change to $ table = $ replace. $ name ['0'];
You can.