Operating System & Version
CLOUDLINUX 7.9
cPanel & WHM Version
94.0.11

Handssler Lopez

Well-Known Member
Apr 30, 2019
65
20
8
Guatemala
cPanel Access Level
Root Administrator
Hello dear, today I have the following question, I want to move or duplicate a database from user1 to user2

the database is very large and it is I need to have this database in another account / another user always from the same server

user1 -> BD move or copy it to user2

if this is not possible.

I have the database in .sql in the / home / directory of the account, what commands should I use to be able to restore the database? over another for example user2_db

** Note ** I have not used the phpmyadmin db import option because this database is several GB.
MariaDB 10.3.29-MariaDB
 
Last edited by a moderator:

kodeslogic

Well-Known Member
Apr 26, 2020
320
121
118
IN
cPanel Access Level
Root Administrator
As a root user, you can use the below command to restore the DB:

Code:
mysql user2_db < db_backup.sql

example: mysql database_name < database-backup-file.sql
After that give privileges to the new user to access the database user2_db
 

HostNoc

Well-Known Member
Feb 20, 2020
83
12
8
Ontario
cPanel Access Level
Root Administrator
HI
Dont use phpmyadmin if your database size is huge and restore your database using following command. Run following command on screen so if you have any issue with internet etc process will run in back ground.

mysql -u [user] -p [database_name] < [filename].sql

Regards
 
  • Like
Reactions: Handssler Lopez

Handssler Lopez

Well-Known Member
Apr 30, 2019
65
20
8
Guatemala
cPanel Access Level
Root Administrator
Code:
mysql user2_db < db_backup.sql

example: mysql database_name < database-backup-file.sql
Thank you very much as I understand this command what it does is restore the .sql file in the database only that I need to be connected to the internet all the time

Code:
mysql -u [user] -p [database_name] < [filename].sql
@HostNoc And with this code I can run it and it will continue in the background as the database to be restored is 20GB, it may take several hours.

Can I run it through terminal, close the terminal, and leave it working during off-peak hours on the server?

@kodeslogic , @HostNoc , @cPRex According to your answers, it means that it is not possible to just copy or move a database from user account1 to user account2. Is this correct or do you consider it to be very complicated and the best are your previous recommendations?

in advance always thank you for your time and attention

I edit: it does not matter that the .sql file is in the / home / of the account or I must change it to the home of the server or put some path in when restoring the database since I plan as root through the terminal navigate to the / home / of the account and there execute the commands

is this action correct?
 
Last edited: