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

The method of changing the name of mysql Database

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

Share

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

This article mainly introduces the method of modifying the name of mysql database, which has certain reference value and can be used for reference by friends who need it. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.

The method to change the name of the mysql database: first create the target database; then get the table names of all source databases; finally, modify them one by one according to the relevant commands, and the code is [rename table srcdb. [tablename] to trgdb. [tablename]].

How to change the name of the mysql database:

1. If it is MyISAM, simply change the name of the folder with the library name under the DATA directory to OK

2. If it is INNODB, in fact, it is impossible to change the name of the library, and dao's RENAME DATABASE or ALTER DATABASE is not allowed on the Internet.

3. One method is relatively conservative, which directly mysqldump the contents of the old library to the new library.

4. There is another method similar to the above. First alter table storage engine to MyISAM, then change the name of the library directory, and then change it back to INNODB.

5. The last method is better. Write it down in detail here.

Assume that the source library name is' srcdb', target library name is' trgdb'

First create the target library

Create database trgdb

Get the table names of all source libraries

Use information_schema;select table_name from TABLES where TABLE_SCHEMA='srcdb'

Then modify them one by one according to the following command

Rename table srcdb. [tablename] to trgdb. [tablename]; Thank you for reading this article carefully. I hope it will be helpful for everyone to share the method of changing the name of mysql database. At the same time, I also hope that you will support us, pay attention to the industry information channel, find out if you encounter problems, and learn detailed solutions!

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