Introduction

Here are some solutions that will hopefully save you time.

Converting a Latin1 Database to UTF8

Here’s the magic command:

  mysqldump --add-drop-table -uroot -p "DB_name" | replace CHARSET=latin1 CHARSET=utf8 | iconv -f latin1 -t utf8 | mysql -uroot -p "DB_name"
  

Adding a Prefix to All Tables in a Database

Here’s how to add a prefix to all tables in a database:

  SELECT Concat('ALTER TABLE ', TABLE_NAME, ' RENAME TO my_prefix_', TABLE_NAME, ';') FROM information_schema.TABLES WHERE table_schema = 'my_database'
  

You just need to replace:

  • my_prefix: with your desired prefix
  • my_database: with the desired database

References

  1. https://steindom.com/articles/adding-prefix-all-tables-mysql-database

Last updated 25 Jan 2013, 16:43 +0200. history