Tag: mariadb

  • Importing a MySQL database with a new name where the original still exists

    So you want to export your MySQL database then import it on the same server with a new name.

     

    I tried this several times and using the SOURCE command inside MySQL or just mysql -p < db.sql both resulted in the database re-importing over the original name.

     

    To fix that run:

    sed -i 's/OLDDATABASENAME/NEWDBNAME/g' mysqldumpFile.sql
    

    Then run:

     

    mysql -p
    
    create NEWDBNAME;
    
    use NEWDBNAME;
    
    SOURCE /path/to/sql/file

     

    No need for a semicolon on the last line.

     

    Then check the success by:

     

    show tables;