Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

[Mysql] change database name operation

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

MySQL introduced a rename database operation in 5. 1, but this command is not supported after MySQL5.1.23. It can be said that it is an experimental feature that has not been supported in production (mysql-5.1 release in mysql-5.1.30), so we sometimes need to change the library name in order to pursue perfection. How do you operate it?

A workaround is provided here.

1. Create a new library name:

Here) collapse or open

Mysql > select concat ("rename table", table_schema, ".", table_name, "to testbak.", table_name, ";") into outfile'/ tmp/rename_to_db_v2.sql' from information_schema.tables where table_schema='test'

[root@host-192-168156 ~] # more / tmp/rename_to_db_v2.sql

Rename table test.bc_dbfsxiang to testbak.bc_dbfsxiang

Rename table test.bc_dkfsxiang to testbak.bc_dkfsxiang

Rename table test.bc_dkytxiang to testbak.bc_dkytxiang

Rename table test.bc_gzffxiang to testbak.bc_gzffxiang

Rename table test.bc_option_map to testbak.bc_option_map

Rename table test.bc_qylxxiang to testbak.bc_qylxxiang

Rename table test.bc_service_city to testbak.bc_service_city

Rename table test.bc_service_qi_city to testbak.bc_service_qi_city

Rename table test.bc_wffkhyxiang to testbak.bc_wffkhyxiang

Rename table test.bc_wffkzyxiang to testbak.bc_wffkzyxiang

Rename table test.bc_xindai to testbak.bc_xindai

Rename table test.bc_xindai_fields_v to testbak.bc_xindai_fields_v

Rename table test.bc_xindai_geren to testbak.bc_xindai_geren

Rename table test.bc_xindai_qiye to testbak.bc_xindai_qiye

Rename table test.bc_xyjlxiang to testbak.bc_xyjlxiang

Rename table test.bc_zyyqxiang to testbak.bc_zyyqxiang

Rename table test.fake_names to testbak.fake_names

Rename table test.idmap to testbak.idmap

Rename table test.sbtest to testbak.sbtest

Rename table test.tbUser to testbak.tbUser

Rename table test.test to testbak.test

Rename table test.test2 to testbak.test2

3 you can execute it.

Click (here) to collapse or open

Mysql > source / tmp/rename_to_db_v2.sql

Original address: http://wubx.net/tips-mysql-rename-database/

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report