MySQL database name modification tutorial, mysql database name modification tutorial

Source: Internet
Author: User

MySQL database name modification tutorial, mysql database name modification tutorial

MySQL introduced a rename database operation in MySQL 5.1, but does not support this command after MySQL5.1.23. It can be said that it is an experimental function, not supported in production (mysql-5.1 release in mysql-5.1.30), so in production we sometimes need to change the library name to the pursuit of perfection. How can this problem be solved?
Here is a work und.
1. Create a new database name:

Mysql> create database db_v2; mysql> create database db_v2;

2. Generate the rename statement and migrate it from olddb. Here I will use sbtest in olddb;

Mysql> select concat ("rename table", table_schema ,". ", table_name," to db_v2. ", table_name,"; ") into outfile '/tmp/rename_to_db_v2. SQL' from information_schema.tables where table_schema = 'sbtest'; mysql> select concat (" rename table ", table_schema ,". ", table_name," to db_v2. ", table_name,"; ") into outfile '/tmp/rename_to_db_v2. SQL' from information_schema.tables where table_schema = 'sbtest ';

3. Execute the generated SQL

Mysql> source/tmp/rename_to_db_v2. SQL mysql> source/tmp/rename_to_db_v2. SQL

That's easy.
Good luck!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.