Forum Moderators: coopster & phranque

Message Too Old, No Replies

MySQL help

possibly rename a database

         

Doood

4:54 pm on Feb 19, 2003 (gmt 0)

10+ Year Member



I hope this is the right place for this question.

I'm using phpmyadmin and I'm trying to rename a database. My current database name has a dash (-) in it and that's apparently a bad thing.

I'm really new to creating databases so I don't know what to do and after all day of searching for help...didn't help.

So I either need to rename the database which doesn't seem possible, create a new database and dump structure and data and paste it over to the new db, dump original db and completely delete the db and create a new one. I just don't know which way to go.

If I just delete the db I have now, will phpmyadmin give me the 'create new database' box just like when there is no db there in the beginning? Can all of this be done by only using phpmyadmin?

Sorry if those are dumb questions but I really can't figure this out.

jatar_k

5:13 pm on Feb 19, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



with phpmyadmin you can do a mysqldump with table structures etc. It saves it as a file that you can then import and it will create the whole db with data.

Try dumping it and then open the file in a text editor. There should be the create db command and you can change all references to the dashed db name and then import it again.

Don't drob the db until you test it, db names will be different so you should be able to have both coexist and then drop the original once you check that it worked.

Doood

5:44 pm on Feb 19, 2003 (gmt 0)

10+ Year Member



Ok, but where is the create db command? When I dump it the only thing that changed is that I have a txt file now.

Say my domain is my-database.com and my db name is my-database_com. When I search in the text file for my-database I find My-Database.com my-database_com and my-database. I'm guessing that I only change the my-database_com to mydatabase_com right?

If I knew how to create a new database I think this would be easy but the create db command line dissappeared after I created the first db. Can I create a new database from phpmyadmin or do I have to create it some other way?

Birdman

6:40 pm on Feb 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your host may only allow you one db, which would explain why you cannot create another one. You may have to drop the original db before importing the one you just dumped.

Doood

7:57 pm on Feb 19, 2003 (gmt 0)

10+ Year Member



I guess you're right about not being able to create more db's. I guess I can't use DELETE DATABASE either because it won't work.

I'm too afraid to drop each table individually and wait to see if I can delete the db and create a new one.

I've been waiting for a week and a half for my host to do it for me but he doesn't have time I guess. He only hosts a few sites so he shouldn't be that busy.

crypto

4:08 am on Feb 20, 2003 (gmt 0)

10+ Year Member



Doood,

I don't think phpmyadmin supports renaming of databases.
For renaming your database you just have to rename the folder with 'my-database_com' to 'mydatabase_com' in the mysql database directory. So ask your server guy to do this. Its just a few minutes job. Otherwise you can dump the data from the database then drop it using phpmyadmin and a create a new one then dump the data back into it.

Doood

4:30 am on Feb 20, 2003 (gmt 0)

10+ Year Member



Yeah I figured out that you can't rename it from phpmyadmin, but can I not just use ftp to rename the folder? I don't think my server guy is going to help me on this.

I don't think I have rights to delete db's, unless I'm doing it all wrong. I've been putting in the SQL query box DROP DATABASE and DELETE DATABASE my-database_com and it says the statements are disabled.

I tried going over to another one of my sites phpmyadmin and tried to drop one that is not being used out of the 5 db's there but it said the same thing.

So either I'm doing something wrong or I don't have rights.

crypto

7:52 am on Feb 20, 2003 (gmt 0)

10+ Year Member



sorry doood, it seems that you don't have rights to drop the database. Only the server guy can do the renaming. You won't be able to see the db folder thru ftp, its generally a separate dir from the users.