Re: How to rename a database

2005-11-04 Thread Peter Brawley

Jesse,

>I need to rename a database. I read somewhere that I could simply stop the
>MySQL database server and rename the folder that contains the data, 
re-start

>MySQL, and I'm good-to-go. However, I tried this, and while it appears to
>have worked initially, when I try to access one of the tables in the
>database, I get the error, "fccamp.activities doesn't exist". When I 
rename

>the folder back to "fccamp_dbo", it works just fine.

It's more complicated than just renaming the directory. Here is what we 
wrote for it:


CREATE PROCEDURE RenameDatabase(
 IN oldname CHAR (64), IN newname CHAR(64)
)
BEGIN
 DECLARE sname CHAR(64) DEFAULT NULL;
 DECLARE rows INT DEFAULT 1;
 DECLARE total INT DEFAULT 0;
 CREATE DATABASE IF NOT EXISTS newname;
 REPEAT
   SELECT table_name INTO sname
   FROM information_schema.tables AS t
   WHERE t.table_schema = oldname
   LIMIT 1;
   SET rows = FOUND_ROWS();
   IF rows = 1 THEN
 SET @scmd = CONCAT( 'RENAME TABLE ', oldname, '.', sname,
' TO ', newname, '.', sname );
 PREPARE cmd FROM @scmd;
 EXECUTE cmd;
 DEALLOCATE PREPARE cmd;
 SET total = total + 1;
   END IF;
 UNTIL rows = 0 END REPEAT;
 IF total > 0 THEN
   SET @scmd = CONCAT( "UPDATE mysql.db SET Db = '",
   newname,
   "' WHERE Db = '", oldname, "'" );
   PREPARE cmd FROM @scmd;
   EXECUTE cmd;
   SET @scmd = CONCAT( "UPDATE mysql.columns_priv SET Db = '",
   newname,
   "' WHERE Db = '", oldname, "'" );
   PREPARE cmd FROM @scmd;
   EXECUTE cmd;
   DEALLOCATE PREPARE cmd;
   FLUSH PRIVILEGES;
 END IF;
END;

PB
http://www.artfulsoftware.com

-

Jesse Castleberry wrote:


I need to rename a database.  I read somewhere that I could simply stop the
MySQL database server and rename the folder that contains the data, re-start
MySQL, and I'm good-to-go.  However, I tried this, and while it appears to
have worked initially, when I try to access one of the tables in the
database, I get the error, "fccamp.activities doesn't exist".  When I rename
the folder back to "fccamp_dbo", it works just fine.

So, how do I rename a database correctly?  I'm using MySQL 5.0 in a Windows
XP environment.

Thanks,
Jesse


 




--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.12.8/161 - Release Date: 11/3/2005


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



How to rename a database

2005-11-04 Thread Jesse Castleberry
I need to rename a database.  I read somewhere that I could simply stop the
MySQL database server and rename the folder that contains the data, re-start
MySQL, and I'm good-to-go.  However, I tried this, and while it appears to
have worked initially, when I try to access one of the tables in the
database, I get the error, "fccamp.activities doesn't exist".  When I rename
the folder back to "fccamp_dbo", it works just fine.

So, how do I rename a database correctly?  I'm using MySQL 5.0 in a Windows
XP environment.

Thanks,
Jesse


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Rename a database

2001-11-24 Thread Karl Uscroft

Ok so I'm using Win98, and with this all I do to rename a database is go
into the MySQL folder then into Data folder and there you have all your
databases in their own folders, and then to change the database name just
change the folders name.  It works for me.  I have no idea how it's done in
MySQL but that's how I do it.

PS I've no idea about Unix and the like.

Karl.


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: Rename a database

2001-11-24 Thread Thomas Kotze`

ALTER TABLE Customers RENAME Customer_Table;

-Original Message-
From: TOMASSONI Dominique [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 23, 2001 7:48 PM
To: 'MySQL_mailing_list'
Subject: Rename a database


Hello the list,

Is it possible to change the name of a database ? And if it is, how ?

Thank you for answers.


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

http://www.mycomax.com";>www.mycomax.com
**

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Rename a Database?

2001-11-16 Thread Michael Brunson

This method will cause problems if you have entries in
you mysql.db table for that database. 

Just make sure you correct your permissions.

On Fri, 16 Nov 2001 11:46:31 -0500, Danny Rathjens
<[EMAIL PROTECTED]> wrote:

| stop mysql
| cd /var/lib/mysql
| mv olddbname newdbname
| start mysql
| 
| [EMAIL PROTECTED] wrote:
| 
| > I searched the archives and the manual online but could not find the
| > answer,
| > I believe this has been covered in the list though. Is it possible to
| > rename a
| > database? If not, is it possible to move/copy a table from a database to a
| > new
| > database? Could someone point me to the details on this?
| > 
| > --
| > Chip

Thanks,
Michael
--
Michael Brunson  504.473.6643
[EMAIL PROTECTED] ICQ: 83163789
  ---   Intercosmos Media Group, Inc.  ---
  www.intercosmos.comwww.directnic.com 

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Rename a Database?

2001-11-16 Thread Danny Rathjens

stop mysql
cd /var/lib/mysql
mv olddbname newdbname
start mysql

[EMAIL PROTECTED] wrote:

> I searched the archives and the manual online but could not find the
> answer,
> I believe this has been covered in the list though. Is it possible to
> rename a
> database? If not, is it possible to move/copy a table from a database to a
> new
> database? Could someone point me to the details on this?
> 
> --
> Chip
> 
> 
> -
> Before posting, please check:
>http://www.mysql.com/manual.php   (the manual)
>http://lists.mysql.com/   (the list archive)
> 
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
> 
> 


-- 
  _.,-*~`^'~*-,._ Danny Rathjens _.,-*~`^'~*-,._
"In mathematics, you don't understand things.
  You just get used to them." -- Johann von Neumann


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Rename a Database?

2001-11-16 Thread chip . wiegand

I searched the archives and the manual online but could not find the
answer,
I believe this has been covered in the list though. Is it possible to
rename a
database? If not, is it possible to move/copy a table from a database to a
new
database? Could someone point me to the details on this?

--
Chip


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php