PDA

View Full Version : PHP database manipulation


redsox9
03-10-2006, 04:49 AM
Okay, so I'm still relatively new to working with PHP databases. Now that I'm getting a better idea of how I want to structure my site, I'd like to modify my databases. Specifically, I would like to do the following:


Take database1 and rename it database2
Move table1 from database2 to database3


I looked at the MySQL account maintenance page and didn't see a solution there. The same is true for phpMyAdmin. Now, I haven't looked to see if I can make a simple edit through SSH/shell access but I wonder if there is an easier way. It's not that I couldn't create backups, delete the old databases, and then create new ones and upload the tables, but...

Any help is appreciated! :)

bonz
03-10-2006, 05:05 AM
You can do these things in phpMyAdmin.

Look in the "operations" tab when viewing at the database level for the database rename commmand, and at the table level for moving/copying tables.

You can do all this from the command line as well in the shell, but phpMyAdmin makes it much easier.

redsox9
03-10-2006, 05:29 AM
Hi, bonz:

Well, I found what you were referring to (thanks!), but when I tried to rename the database I got the following error message:

SQL query:

CREATE DATABASE `fenwayfa_db1` ;

MySQL said:

#1044 - Access denied for user 'fenwayfa'@'localhost' to database 'fenwayfa_db1'

Any thoughts? I'm perplexed... :confused:

I haven't tried moving the tables yet but will give that a go next...

Maggilove
03-10-2006, 05:40 AM
Did you remember to add yourself as a user (with all privileges) when you created the database?

bonz
03-10-2006, 05:59 AM
I'm guessing then that our accounts don't have the correct priveleges to operate at the database level through phpMyAdmin. The clue there is that we cannot create new databases via phpMyAdmin (see the red X on the phpmyadmin page next to the create db command?)

I'd look to a BH person to give the authorative answer here, but I think they're forcing us through cpanel to operate on databases. So, I think you're stuck creating the a new database via CPanel and copying tables over via phpMyAdmin.

(You shouldn't have to add yourself as a user, since you're only using your regular account, that should automatically have all the privileges available.)

redsox9
03-10-2006, 06:17 AM
Bonz, I think that you hit the nail on the head because I noticed that, too. We must be on the same wavelength because I did exactly what you suggested before I read your second reply: I created a new database through the cPanel interface and then just copied the tables from the old databases to the new ones through MySQL. Then, once I modified my scripts to reflect this change, I just deleted the old databases through the cPanel interface.

Well, at least I have some control... :rolleyes:

... and yes, I did have admin privileges turned on through cPanel, though sometimes the simpliest explanation is the right one. :)

Maggilove
03-10-2006, 08:58 AM
Sorry... it was a fleeting visit, and I didn't actually read the thread... :o

I guess this must be a new thing... I have accounts on two boxes, and I have full permissions on both... but I just checked a more recent account I have been working on for a friend and, like you, he has the red x. :(