Results 1 to 4 of 4

Thread: Rename mysql database

  1. #1
    Join Date
    Oct 2009
    Posts
    10

    Rename mysql database

    Does any one know the command to rename mysql database. I have created a database with name database1 and now i want to convert or change that name in to database2. What are syntax use in mysql to change the database name. I have tried to change that from command
    Code:
    rename database database TO database1
    and it says its invalid syntax by database..

  2. #2
    Join Date
    Jan 2009
    Posts
    199

    Re: Rename mysql database

    If you're renaming the DB by command line, you'll want to grant user permissions to the new DB and delete permissions granted for the old DB.you can just rename the folders that store the databases while the server is. But that doesn't work when you have at least one InnoDB table, because renaming folders wrecks the tablespace. But that does not work when you have at least one InnoDB tableYou either run an SQL query to do this or do it with phpMyAdmin if you don't want to bother remembering the SQL to do so.

  3. #3
    Join Date
    May 2008
    Posts
    2,297

    Re: Rename mysql database

    Use the following code to rename mysql database
    Code:
    mv databse databse1
    
    cd database/
    
    mv databse.frm database1.frm
    
    mv databse.MYD database1.MYD
    
    mv databse.MYI databse1.MYI
    
    Restart MySQL
    
    /etc/init.d/mysql start

  4. #4
    Join Date
    Dec 2008
    Posts
    177

    Re: Rename mysql database

    MySQL does not support a database rename command. If MySQL has no command for renaming a database then the safest way is to use mysqldump to back up the old database, then restore the dump. Using mysqldump, dump the database. The mysqldump client can be used to dump a database or a collection of databases for backup or for transferring the data to another SQL server.

Similar Threads

  1. Manipulating MySQL database using PHP
    By blueprats in forum Guides & Tutorials
    Replies: 1
    Last Post: 30-04-2010, 04:29 PM
  2. How to speed up the MySQL database
    By Kalanidhi in forum Software Development
    Replies: 5
    Last Post: 27-02-2010, 01:33 AM
  3. Replies: 3
    Last Post: 07-11-2009, 09:36 PM
  4. Backup mysql database
    By jean-paul martell in forum Software Development
    Replies: 3
    Last Post: 31-10-2009, 01:10 PM
  5. How to Connect MySQL database from PHP
    By Booth in forum Software Development
    Replies: 3
    Last Post: 21-01-2009, 09:12 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,619,984.85683 seconds with 16 queries