how i create mysql file in via ssh

Discussion in 'MySQL' started by Mazaonline, Jan 8, 2008.

  1. #1
    HEllo i have forums,now i want to move my data to new host, how can i create mysql data via ssh ?
     
    Mazaonline, Jan 8, 2008 IP
  2. MakeADifference

    MakeADifference Peon

    Messages:
    476
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Do you have Access to PhpMyAdmin? Most cpanel powered server has it. you can export the database from there.
     
    MakeADifference, Jan 8, 2008 IP
  3. chrissyj

    chrissyj Peon

    Messages:
    56
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You will need the database username, password and database name.
    After you ssh into OLD server, type "mysqldump -u USER_NAME -p DB_NAME | gzip > FILE.sql.gz"
    Enter the database password when it asks. Then, usinf FTP or sFTP, copy the FILE.sql.gz file from the OLD server to the NEW server. (Presumably by copying it from OLD server to your PC and then to NEW server.)
    After you ssh into NEW server, type "gunzip < FILE.sql.gz | mysql -u USER_NAME -p DB_NAME"
    Enter the database password when it asks. When it is done, your database will be copied to the new server.

    PM me if you need more help.
     
    chrissyj, Jan 8, 2008 IP
    Lever likes this.
  4. jigolo

    jigolo Peon

    Messages:
    312
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    It's actually rather easy to do through ssh:

    Login to old host:
    Commands:
    First, dump the database to a file.
    mysqldump database -uusername -ppassword > database.sql

    then open an FTP session to your new host:

    ncftp -uuser new-host

    then put the file dump on the new server. Navigate to any appropriate directory first:

    put database.sql

    Exit twice, first to close the FTP session, and the SSH session:
    exit
    exit

    ssh to new host (make sure the database actually exists!)

    mysql database -uusername -p < database.sql
    or simply mysql database -uusername -p
    enter password
    source database.sql

    by: Web Hosting Talk
     
    jigolo, Jan 10, 2008 IP