Copy a database from one account to another account by ssh
Hi,
I want to copy a database from one account to another account that I have on the same server.
I usually do this when it comes to the same account
mysqldump -u user -p'password 'nameBD | ssh user @ the IP mysql -u user -p'password 'DBcopy.
But I can not find a way to do it between 2 different accounts.
The database is very large is the reason why I use the ssh.
thanks for your help
-
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. 0 -
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.sql0 -
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.0
Please sign in to leave a comment.
Comments
4 comments