Renaming table name prefixes in phpmyadmin?

Is there a more dynamic way to rename all the prefixes in the database to phpmyadmin, instead of manually typing to replace the name for each table? I have about 50 tables to change the prefixes to ... Maybe I should grab the compressors panel?

+6
source share
5 answers

You have all the relevant tables in phpMyadmin and select With Selected.. Replace table prefix

+40
source
  • Click / open the database.

  • Click Structure in the top pane.
    This will display all your tables. Pay attention to the existing prefix .

  • Scroll down to the last table.

  • Click Check All .
    This will check all the tables.

  • Select the drop-down menu next to it - the default value is "with selected . "

  • Select "Replace table prefix:"
    This will lead you to a new page with two text entries.

  • Fill in an existing prefix, for example. "OldPrefi_". Do not forget to emphasize.

  • Fill in a new prefix, for example. "NewPrefi_". Do not forget to emphasize.

  • Finally, click submit .

You will be redirected to the list of tables with the new prefix.

+5
source

I solved it! It is easy to download sql file from phpmyadmin. Opening a file in Notepad ++. Search and replace all prefixes (i.e. Etc_ with dem_). Then save the sql file. Change the prefix values ​​in your php code that communicates with the database. Then go back to your database, back up. Then delete all the tables and install the .sql file that you just changed in notepad ++. Easy!

+4
source

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

In phpMyAdmin, select Custom Output. In the "Object creation options" section, check the "ADD DROP TABLE" / "..." checkbox. Export to text or file as usual and open in your preferred text editor. You will notice that now there are two rows for each table: DROP TABLE IF EXISTS prefix_tablename; and CREATE TABLE IF NOT EXISTS prefix_tablename

Step 1: Find and replace all "prefix_" with "theprefixyouwant_". Now it looks like this:

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

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

Save. Run / import SQL. Done.

This will delete all source tables without query. Make sure that you have a secure database backup on file only in case of emergency. As with the original solution, do it at your own peril and risk, however I just did it at three small production sites without problems.

+4
source

Check the tables you want to change (shift works for lists) Scroll down the page and open the "With selected:" drop-down list and select "Replace table prefix", Fill in the from and too field and click the Submit button.

+1
source

Source: https://habr.com/ru/post/900791/


All Articles