Home >Database >Mysql Tutorial >How to change the database name in mysql?

How to change the database name in mysql?

藏色散人
藏色散人Original
2019-05-20 14:05:5028952browse

How to change the database name in mysql?

The method to modify the MySQL database name is as follows:

1. Statement modification method:

RENAME DATABASE db_name TO new_db_name

This syntax was added in mysql 5.1.7 and removed in 5.1.23.

2. If all tables are of MyISAM type, you can change the name of the folder

Rename the db_name directory in the data directory to new_db_name

3. Rename all tables

The code is as follows:

How to change the database name in mysql?

4. Mysqldump exports the data and then imports it

The code is as follows:

How to change the database name in mysql?

5. Use shell script to rename all tables

The code is as follows :

How to change the database name in mysql?

Related learning recommendations: mysql database

##

The above is the detailed content of How to change the database name in mysql?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn