Renaming a MySQL Database.

+2 votes
Hi guys,

 

I need to rename my database from bddjalp_dbase1 to testdb_dbase1 ( The Prefix ) How would I go about doing this?

I'm using MySQL and my own self managed cPanel server.

 

In which ways will I be able to do this using for the below

1) Self managed cPanel server
2) Your shared hosting servers
asked Apr 21, 2015 in Shared Hosting by MurdR93 (6,070 points)

2 Answers

0 votes
You will be able to do this in both the service that you choose. The these servers have PHP MyAdmin which the toon you will use to change or rename the database. You would need to export the database from PHP MyAdmin, of which the database will be downloaded to your local computer in a .sql format. You can rename it from your computer but keep the same format and import it from PHP MyAdmin again to what you renamed it to be.

It is not advisable to change to change the prefix on the database name because it is the username for your domain. You would need to chnage the suffix. This will allow you to connect the new databse on different sites to run your tests.
answered Apr 21, 2015 by AfriDude (43,950 points)
0 votes

Hi,

It's possible to change on a self managed server but on shared hosting it might not be possible. The username prefix will always be added to the new name you rename to using phpMyAdmin.

Before You Begin

For cPanel: If you want the same database user to have access to the renamed database, you should take note of the username already assigned to the database, which may or may not be similar to the name of the current database.

  1. In cPanel, click on MySQL Databases.
  2. Scroll down to the Current Databases section of the page.
  3. Find the database you are about to rename, and take note or remember the database user already assigned to the database.  You will need to know this for step 2.
  4. You can return to the cPanel home screen to begin Step 1.

Step 1: Renaming the Database

  1. From cPanel, click on phpMyAdmin. (It should open in a new tab.)
  2. Click on the database you wish to rename in the left hand column.
  3. Click on the Operations tab.
  4. Where it says "Rename database to:" enter the new database name.
  5. Click the Go button.
  6. When it asks you to want to create the new database and drop the old database, click OK to proceed. (This is a good time to make sure you spelled the new name correctly.)
  7. Once the operation is complete, click OK when asked if you want to reload the database.

 

As a hack on a self managed cpanel server, you could could create the account of the domain you want with the username testdb then all the databases you create on this profile/account will by default have the prefix testdb_

 

answered Apr 21, 2015 by theeandre (32,960 points)
...