{"id":3386,"date":"2026-03-30T18:54:42","date_gmt":"2026-03-30T16:54:42","guid":{"rendered":"https:\/\/digitalia.culturanuova.net\/blog\/?p=3386"},"modified":"2026-03-30T18:58:38","modified_gmt":"2026-03-30T16:58:38","slug":"mysql-multiple-rename","status":"publish","type":"post","link":"https:\/\/digitalia.culturanuova.net\/blog\/?p=3386","title":{"rendered":"mysql multiple tables rename"},"content":{"rendered":"\n<p>To rename many mysql\/mariadb tables with a same prefix, you can uso this script (in a terminal)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql -u root -p -N -e \" SELECT CONCAT('RENAME TABLE \\', table_name, '\\ TO \\', REPLACE(table_name, 'oldprefix_', 'newprefix_'), '\\;') FROM information_schema.tables WHERE table_schema = 'your-database' AND table_name LIKE 'oldprefix_%'; \" &gt; renamed.sql <\/code><\/pre>\n\n\n\n<p>In this way will created the file renamed.sql (same tables, with different names), that you then can use to replace your database, with<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql -u root -p yourdatabase &lt; renamed.sql<\/code><\/pre>\n\n\n\n<p>If you have a <strong>wordpress<\/strong> database you have also to check options and meta tables, removing oldprefixes, with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>UPDATE oldprefix_options\nSET option_name = REPLACE(option_name, 'oldprefix_', 'newprefix_')\nWHERE option_name LIKE 'oldprefix\\_%';<\/code><\/pre>\n\n\n\n<p>and<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>UPDATE abc_usermeta\nSET meta_key = REPLACE(meta_key, 'oldprefix_', 'newprefix_')\nWHERE meta_key LIKE 'oldprefix\\_%';<\/code><\/pre>\n\n\n\n<p>And finally, you could check if there are any oldprefix, in <strong>options<\/strong> with<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT option_name FROM newprefix_options WHERE option_name LIKE 'oldprefix\\_%';<\/code><\/pre>\n\n\n\n<p>same for <strong>meta<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT meta_key FROM newprefix_usermeta WHERE meta_key LIKE 'oldprefix\\_%';<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>To rename many mysql\/mariadb tables with a same prefix, you can uso this script (in a terminal) In this way will created the file renamed.sql (same tables, with different names), that you then can use to replace your database, with If you have a wordpress database you have also to check options and meta tables, &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/digitalia.culturanuova.net\/blog\/?p=3386\" class=\"more-link\">Leggi tutto<span class=\"screen-reader-text\"> &#8220;mysql multiple tables rename&#8221;<\/span><\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[870,885,579,566],"tags":[34,11,709,1002,488],"class_list":["post-3386","post","type-post","status-publish","format-standard","hentry","category-blogs","category-code","category-database","category-webmaster","tag-mariadb","tag-mysql","tag-mysql-replace","tag-tables","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3386","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3386"}],"version-history":[{"count":5,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3386\/revisions"}],"predecessor-version":[{"id":3391,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3386\/revisions\/3391"}],"wp:attachment":[{"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3386"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3386"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3386"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}