Blog Bustle 21/02/2020
Sometimes we have to change the database name according to our need and we do not have any other option. Mysql rename database command line was used to change the database name in mysql older versions but it has been removed from mysql latest versions because of security reasons.
rename database old_database_name to new_database_name;
This mysql rename database command line no longer works.
So how can we rename mysql database?
Step 1: export database whom you want to rename
Step 2: create database with new_database_name
Step 3: import database backup file into new database
This is the safe mysql rename database method.
For example, i want to change the name of student database. So first we export student database
mysqldump -u [username] -p [password] [database_name] > [dump_file_name.sql]
i am using local server. In my case, export mysql database command line will be
mysqldump -u root -p student > d:\student.sql
We know we use mysqldump tool for export database. In this export mysql database command line username is root, password is empty, database is student and dump file name is student.sql
I wanted to rename student database by college database. So i am going to create college database.
Create database syntax will be
create database college;
so we have taken student database backup and created college database. Our next step is to import student database backup file into college database.
mysql -u [username] -p [password] [database_name] < [dump_file_name.sql]
In my case, import mysql database command line will be
mysql -u root -p college < d:\student.sql
Rename mysql database method is very useful when we have to change the database name according to our need or we create wrong database by mistake.
Sql Insert Query
Sql Update Query
Sql & Mysql difference
Sql Delete Query
Sql Select Query
Mysql no database selected error 1046
Sql Create Table
Sql Drop Table
Sql Alter Query(add, drop, modify & change column)
Sql Truncate Table
Sql Insert Into Query
Sql Rename Table
Sql DISTINCT Keyword
Sql WHERE Clause
Sql Like operator
Sql AND operator
Sql OR operator
Sql NOT operator
Combining Sql AND, OR & NOT operator
Sql IN operator
Sql NOT IN operator
Sql Count, Sum, Avg, Min, Max
Sql Order By clause
Sql Limit clause
Sql BETWEEN operator
Sql Group By clause
Sql Aliases
Sql Inner Join
Sql Left Join
Sql Right Join
Mysql Create Database
Mysql Create Database Command Line
Mysql Delete Database
Mysql Delete Database Command Line
Mysql Show Databases
Mysql Show Databases Command Line
Mysql Select Database
Mysql Select Database Command Line
Mysql Backup Database
Mysql Import Database
Mysql Copy Database
Mysql Rename Database
Truncate Database Mysql