Skip to main content

Copy a database from one account to another account by ssh



  • Eminds
    if you are looking to use same database for 2 different accounts on the same servers, backup the database first, then from cpanel create a new database for the another website from cpanel and restore the backup to that newely created database.
  • 24x7server
    But I can not find a way to do it between 2 different accounts.

    Support you want to copy database from one user to another shell, so the question is what shell level access do you have, root access or a user access? If you have root access, perform the below steps: 1. Login to the server. 2. Create dump of the database using mysqldump command. # mysqldump -u -p user1DB > user1DB.sql 3. Create a new database under user2. 4. restore the dump you created in step 2 on this user using below command; # mysql -u -p user2DB < user1DB.sql
  • pbixdesign
    Thank you Eminds, That's the first thing I did, but since the database is too big, I always have errors and i never copy the entire database. we Can not do with ssh? Thank you
  • cPWilliamL
    we Can not do with ssh?

    Certainly, perform this on the destination server: ssh usr@remote-host mysqldump -u dbuser -ppasswd db_name|gzip >db_name.sql.gz
    If you are accessing the remote host via root, you can skip the '-u dbuser -ppasswd' part. If accessing the remote server via cPanel user, you'll need to use correct username/password for SSH and for the database user. Once completed, use `gunzip db_name.sql.gz' to extract it. Then import it into a database you created via cPanel, as described above.

Please sign in to leave a comment.