It is one of the most widely used web-based MySQL management tools for hosting companies. where it says 'Copy database to:' type in the name of the new database. mysql -u username -p 'password' newDbName < oldDbName.sql. Lastly, with the new database created, use mysql to import the dump file we created into the new database. mysqladmin -u username -p 'password' create newDbName. A free and open-source program for managing MySQL databases is called phpMyAdmin. Ok, so if the rename option doesnt show, here a quick way of cloning a database using phpMyAdmin: Open the database you want to copy Click the Operations tab. Next use the mysqladmin command to create a new database. Params=$($mysqlconn -N -e "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='$olddb'") In this article, we will show you how to rename a database using phpMyAdmin. $mysqlconn -e "CREATE DATABASE \`$newdb\`" Mysqlconn="mysql -u $dbuser -p$dbpass -h localhost" Write a simple Linux script (my favorite solution) #!/bin/bash Mysql -uxxxx -pxxxx -h xxxx -e "DROP DATABASE db_name" Mysql -uxxxx -pxxxx -h xxxx new_db_name < db_name_dump.sql phpmyadmin - MySQL - Renaming database - Stack Overflow MySQL - Renaming database Ask Question Asked 7 years, 7 months ago Modified 7 years, 7 months ago Viewed 3k times 0 Using PHPMyAdmin version 4.5.2 and SQL 5.7.9. Mysql -uxxxx -pxxxx -h xxxx -e "CREATE DATABASE new_db_name" mysqldump -uxxxx -pxxxx -h xxxx db_name > db_name_dump.sql This option can perform badly for large database. Finally, use the drop database command to drop the old database. In Linux shell, use mysqldump to back up the old database, then restore the dumped database under a new name using the MySQL utility. This is the basic structure of the command: mysql -u dbUsername -p 'dbPassword' oldDatabase -sNe show tables while read table do mysql -u dbUsername -p 'dbPassword' -sNe 'RENAME TABLE oldDatabase.table TO newDatabase. RENAME TABLE db_name.table1 TO new_db_name.table1, db_name.table2 TO new_db_name.table2 In order to rename a MySQL database you can do one of the following:Ĭreate new database and rename all tables in the old database to be in the new database: CREATE database new_db_name In MySQL there is no support for database renaming.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |