database 在 phpmyadmin 中重命名表名的前缀?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8012776/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 08:22:29  来源:igfitidea点击:

Renaming prefixes of table names within phpmyadmin?

databasephpmyadminrenameprefix

提问by klewis

Is there a more dynamic way to rename all prefixes in a database within phpmyadmin, rather than manually typing to replace the name for each table? I have about 50 tables to change prefixes on... Maybe I should grab a snickers bar?

是否有更动态的方法来重命名 phpmyadmin 中数据库中的所有前缀,而不是手动键入以替换每个表的名称?我有大约 50 个表要更改前缀...也许我应该拿一个士力架吧?

回答by Thomas

Have all the corresponding tables in phpMyadmin ticked and select With Selected..->Replace table prefix

勾选phpMyadmin中所有对应的表并选择With Selected..->Replace table prefix

回答by xngigez

  1. Click/open the database.

  2. Click Structureat the top bar.
    This will display all your tables. Note the existing prefix.

  3. Scroll to the bottom, to the last table.

  4. Click "Check all".
    This will check all tables.

  5. Click the drop down menu just next to it - the one with the default value "with selected".

  6. Select "Replace table prefix:"
    This will bring you to a new page with two text inputs.

  7. Fill in your existing prefix, e.g. "oldPrefi_". Don't forget the underscore.

  8. Fill in your new prefix, e.g. "newPrefi_". Don't forget the underscore.

  9. Finally, click submit.

  1. 单击/打开数据库。

  2. 单击顶部栏中的结构
    这将显示您的所有表格。注意现有的前缀

  3. 滚动到底部,到最后一个表格。

  4. 单击“全部检查”
    这将检查所有表。

  5. 单击它旁边的下拉菜单 - 具有默认值"with selected"的下拉菜单。

  6. 选择“替换表前缀:”
    这将带您进入一个包含两个文本输入的新页面。

  7. 填写您现有的前缀,例如“oldPrefi_”。不要忘记下划线。

  8. 填写您的新前缀,例如“newPrefi_”。不要忘记下划线。

  9. 最后,点击提交

You will be redirected to the table list with the new prefix.

您将被重定向到具有新前缀的表列表。

回答by klewis

Here is one way..It's easy as downloading the SQL file from phpmyadmin. Opening the file in Notepad++. Search and Replace all Prefixes (i.e. etc_ with dem_). Then save the sql file. Change the prefix values within your php code that is communicating with the database. Then go back to your database, back it up. Then delete all the tables and install the .sql file you just modified in notepad++. Easy!

这是一种方法..就像从phpmyadmin下载SQL文件一样简单。在 Notepad++ 中打开文件。搜索并替换所有前缀(即 etc_ 与 dem_)。然后保存sql文件。更改与数据库通信的 php 代码中的前缀值。然后回到你的数据库,备份它。然后删除所有表,安装刚才在notepad++中修改的.sql文件。简单!

回答by user2051698

An easy way is to let the script delete the tables for you. Much faster on large database sites like Joomla or WordPress.

一个简单的方法是让脚本为您删除表。在 Joomla 或 WordPress 等大型数据库站点上速度要快得多。

In phpMyAdmin choose Custom output. Under Object Creation Options, check the box to ADD DROP TABLE / .... Export to text or file as usual and open in preferred text editor. You will notice there are two lines for each table now: DROP TABLE IF EXISTS prefix_tablename;and CREATE TABLE IF NOT EXISTS prefix_tablename

在 phpMyAdmin 中选择自定义输出。在 Object Creation Options 下,选中 ADD DROP TABLE / .... 像往常一样导出到文本或文件并在首选文本编辑器中打开的框。您会注意到现在每个表都有两行:DROP TABLE IF EXISTS prefix_tablename;CREATE TABLE IF NOT EXISTS prefix_tablename

Step 1:Search and replace all 'prefix_' with 'theprefixyouwant_' This should now look like:

第 1 步:搜索所有 'prefix_' 并将其替换为 'theprefixyouwant_' 现在应该如下所示:

DROP TABLE IF EXISTS 'theprefixyouwant_'and CREATE TABLE IF NOT EXISTS 'theprefixyouwant_'

DROP TABLE IF EXISTS 'theprefixyouwant_'CREATE TABLE IF NOT EXISTS 'theprefixyouwant_'

Step 2:Search and replace all DROP TABLE IF EXISTS 'theprefixyouwant_'with DROP TABLE IF EXISTS 'prefix_'.

第 2 步:搜索并全部替换DROP TABLE IF EXISTS 'theprefixyouwant_'DROP TABLE IF EXISTS 'prefix_'.

Save. Run / import SQL. Done.

节省。运行/导入 SQL。完毕。

This WILL delete all your original tables without prompting. Make certain you have a safe DB backup on file just in case of emergencies. As with the original solution, do this at your own risk, however I just did it on three small production sites without issue.

这将在没有提示的情况下删除所有原始表。确保您有一个安全的数据库备份文件,以防万一。与最初的解决方案一样,这样做的风险由您自己承担,但是我只是在三个小型生产站点上这样做没有问题。

回答by Rob Frost

Check the tables you wish to change (shift click works for lists) Scroll to the bottom of your tables and open the "With Selected:" dropdown and choose "Replace table prefix" Fill in the from and too box and click submit.

检查您想要更改的表格(Shift 单击适用于列表)滚动到表格底部并打开“With Selected:”下拉菜单并选择“Replace table prefix”填写 from and too 框并点击提交。