I have exported all my databases to a file using phpMyAdmin.
Unfortunately I don't have a working phpMyAdmin in my destination system.
How should I restore all of them at once using one line command?
mysql phpmyadmin
add a comment |
I have exported all my databases to a file using phpMyAdmin.
Unfortunately I don't have a working phpMyAdmin in my destination system.
How should I restore all of them at once using one line command?
mysql phpmyadmin
1
Did you take a look into the file? It should/could contain commands to create and switch to the databases as needed.
– Tom Regner
Oct 9 '12 at 12:42
Yes, databases are created and then they have been selected usingUSE database_name
command.
– smhnaji
Oct 9 '12 at 12:45
Then Unni and laurents answers are correct.
– Tom Regner
Oct 9 '12 at 13:14
add a comment |
I have exported all my databases to a file using phpMyAdmin.
Unfortunately I don't have a working phpMyAdmin in my destination system.
How should I restore all of them at once using one line command?
mysql phpmyadmin
I have exported all my databases to a file using phpMyAdmin.
Unfortunately I don't have a working phpMyAdmin in my destination system.
How should I restore all of them at once using one line command?
mysql phpmyadmin
mysql phpmyadmin
edited Jan 30 '14 at 0:48
Flyk
1,38931624
1,38931624
asked Oct 9 '12 at 12:29
smhnajismhnaji
2021211
2021211
1
Did you take a look into the file? It should/could contain commands to create and switch to the databases as needed.
– Tom Regner
Oct 9 '12 at 12:42
Yes, databases are created and then they have been selected usingUSE database_name
command.
– smhnaji
Oct 9 '12 at 12:45
Then Unni and laurents answers are correct.
– Tom Regner
Oct 9 '12 at 13:14
add a comment |
1
Did you take a look into the file? It should/could contain commands to create and switch to the databases as needed.
– Tom Regner
Oct 9 '12 at 12:42
Yes, databases are created and then they have been selected usingUSE database_name
command.
– smhnaji
Oct 9 '12 at 12:45
Then Unni and laurents answers are correct.
– Tom Regner
Oct 9 '12 at 13:14
1
1
Did you take a look into the file? It should/could contain commands to create and switch to the databases as needed.
– Tom Regner
Oct 9 '12 at 12:42
Did you take a look into the file? It should/could contain commands to create and switch to the databases as needed.
– Tom Regner
Oct 9 '12 at 12:42
Yes, databases are created and then they have been selected using
USE database_name
command.– smhnaji
Oct 9 '12 at 12:45
Yes, databases are created and then they have been selected using
USE database_name
command.– smhnaji
Oct 9 '12 at 12:45
Then Unni and laurents answers are correct.
– Tom Regner
Oct 9 '12 at 13:14
Then Unni and laurents answers are correct.
– Tom Regner
Oct 9 '12 at 13:14
add a comment |
4 Answers
4
active
oldest
votes
Why don't you concat all the files into one single file and import/restore using
mysql -u username -p < dump.sql
Create one file using
mysqldump -u username -p --all-databases > dump.sql
The OP already has a single file and he needs to restore the files so he can't dump them anymore I suppose.
– laurent
Oct 9 '12 at 12:59
@laurent Yes got it. Usingmysql -u username -p < dump.sql
will load the multiple mysql database.
– devav2
Oct 9 '12 at 13:05
yes, sure it will
– laurent
Oct 9 '12 at 13:07
2
it did not work for me. it says i need to select a databse
– Aryeh Armon
Jul 7 '15 at 9:22
add a comment |
If you backed up many database to 1 file, I suppose you backed up the create database
statements in the same file. If not you only need to add the create database
and use database
statements to your file at the proper places.
After that, the command to load the file to mysql is:
mysql -p < sqlfile.sql
-p
is to ask for your password.
You can use -u username
if you need to use another user.
add a comment |
mysql command to restore sql file is :
mysql DATABASE_NAME < SQL_FILENAME.sql
first make sure that file is sql. Incase it ends with gz file extension, you need to uncompress using command :
gunzip SQL_FILE.sql.gz
-1 . As I said in the above, there are MULTIPLE databases stored in the file and I want all of them to be restored at once.
– smhnaji
Oct 9 '12 at 12:38
can you export each database separately in phpmyadmin and restore it at source server ? or use linux stream editors such as sed or awk to split them in different file.
– Unni
Oct 9 '12 at 12:47
1
no need, he can import all the databases from a single file
– laurent
Oct 9 '12 at 13:01
add a comment |
You may restore databases with the help of sql 2005 repair database
http://www.sqlserverrepairtoolbox.com repairs data types, views, procedures, tables, keys, indexes and other objects
This does not answer the original question. SQL Server Repair Toolbox is a proprietary Windows program that does not work from the Ubuntu command line.
– karel
4 hours ago
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f198170%2frestoring-multiple-mysql-databases-from-one-file-at-the-command-line%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
Why don't you concat all the files into one single file and import/restore using
mysql -u username -p < dump.sql
Create one file using
mysqldump -u username -p --all-databases > dump.sql
The OP already has a single file and he needs to restore the files so he can't dump them anymore I suppose.
– laurent
Oct 9 '12 at 12:59
@laurent Yes got it. Usingmysql -u username -p < dump.sql
will load the multiple mysql database.
– devav2
Oct 9 '12 at 13:05
yes, sure it will
– laurent
Oct 9 '12 at 13:07
2
it did not work for me. it says i need to select a databse
– Aryeh Armon
Jul 7 '15 at 9:22
add a comment |
Why don't you concat all the files into one single file and import/restore using
mysql -u username -p < dump.sql
Create one file using
mysqldump -u username -p --all-databases > dump.sql
The OP already has a single file and he needs to restore the files so he can't dump them anymore I suppose.
– laurent
Oct 9 '12 at 12:59
@laurent Yes got it. Usingmysql -u username -p < dump.sql
will load the multiple mysql database.
– devav2
Oct 9 '12 at 13:05
yes, sure it will
– laurent
Oct 9 '12 at 13:07
2
it did not work for me. it says i need to select a databse
– Aryeh Armon
Jul 7 '15 at 9:22
add a comment |
Why don't you concat all the files into one single file and import/restore using
mysql -u username -p < dump.sql
Create one file using
mysqldump -u username -p --all-databases > dump.sql
Why don't you concat all the files into one single file and import/restore using
mysql -u username -p < dump.sql
Create one file using
mysqldump -u username -p --all-databases > dump.sql
edited 9 hours ago
Pablo Bianchi
2,4451530
2,4451530
answered Oct 9 '12 at 12:51
devav2devav2
24.7k126979
24.7k126979
The OP already has a single file and he needs to restore the files so he can't dump them anymore I suppose.
– laurent
Oct 9 '12 at 12:59
@laurent Yes got it. Usingmysql -u username -p < dump.sql
will load the multiple mysql database.
– devav2
Oct 9 '12 at 13:05
yes, sure it will
– laurent
Oct 9 '12 at 13:07
2
it did not work for me. it says i need to select a databse
– Aryeh Armon
Jul 7 '15 at 9:22
add a comment |
The OP already has a single file and he needs to restore the files so he can't dump them anymore I suppose.
– laurent
Oct 9 '12 at 12:59
@laurent Yes got it. Usingmysql -u username -p < dump.sql
will load the multiple mysql database.
– devav2
Oct 9 '12 at 13:05
yes, sure it will
– laurent
Oct 9 '12 at 13:07
2
it did not work for me. it says i need to select a databse
– Aryeh Armon
Jul 7 '15 at 9:22
The OP already has a single file and he needs to restore the files so he can't dump them anymore I suppose.
– laurent
Oct 9 '12 at 12:59
The OP already has a single file and he needs to restore the files so he can't dump them anymore I suppose.
– laurent
Oct 9 '12 at 12:59
@laurent Yes got it. Using
mysql -u username -p < dump.sql
will load the multiple mysql database.– devav2
Oct 9 '12 at 13:05
@laurent Yes got it. Using
mysql -u username -p < dump.sql
will load the multiple mysql database.– devav2
Oct 9 '12 at 13:05
yes, sure it will
– laurent
Oct 9 '12 at 13:07
yes, sure it will
– laurent
Oct 9 '12 at 13:07
2
2
it did not work for me. it says i need to select a databse
– Aryeh Armon
Jul 7 '15 at 9:22
it did not work for me. it says i need to select a databse
– Aryeh Armon
Jul 7 '15 at 9:22
add a comment |
If you backed up many database to 1 file, I suppose you backed up the create database
statements in the same file. If not you only need to add the create database
and use database
statements to your file at the proper places.
After that, the command to load the file to mysql is:
mysql -p < sqlfile.sql
-p
is to ask for your password.
You can use -u username
if you need to use another user.
add a comment |
If you backed up many database to 1 file, I suppose you backed up the create database
statements in the same file. If not you only need to add the create database
and use database
statements to your file at the proper places.
After that, the command to load the file to mysql is:
mysql -p < sqlfile.sql
-p
is to ask for your password.
You can use -u username
if you need to use another user.
add a comment |
If you backed up many database to 1 file, I suppose you backed up the create database
statements in the same file. If not you only need to add the create database
and use database
statements to your file at the proper places.
After that, the command to load the file to mysql is:
mysql -p < sqlfile.sql
-p
is to ask for your password.
You can use -u username
if you need to use another user.
If you backed up many database to 1 file, I suppose you backed up the create database
statements in the same file. If not you only need to add the create database
and use database
statements to your file at the proper places.
After that, the command to load the file to mysql is:
mysql -p < sqlfile.sql
-p
is to ask for your password.
You can use -u username
if you need to use another user.
edited Oct 9 '12 at 13:02
answered Oct 9 '12 at 12:48
laurentlaurent
5,2091923
5,2091923
add a comment |
add a comment |
mysql command to restore sql file is :
mysql DATABASE_NAME < SQL_FILENAME.sql
first make sure that file is sql. Incase it ends with gz file extension, you need to uncompress using command :
gunzip SQL_FILE.sql.gz
-1 . As I said in the above, there are MULTIPLE databases stored in the file and I want all of them to be restored at once.
– smhnaji
Oct 9 '12 at 12:38
can you export each database separately in phpmyadmin and restore it at source server ? or use linux stream editors such as sed or awk to split them in different file.
– Unni
Oct 9 '12 at 12:47
1
no need, he can import all the databases from a single file
– laurent
Oct 9 '12 at 13:01
add a comment |
mysql command to restore sql file is :
mysql DATABASE_NAME < SQL_FILENAME.sql
first make sure that file is sql. Incase it ends with gz file extension, you need to uncompress using command :
gunzip SQL_FILE.sql.gz
-1 . As I said in the above, there are MULTIPLE databases stored in the file and I want all of them to be restored at once.
– smhnaji
Oct 9 '12 at 12:38
can you export each database separately in phpmyadmin and restore it at source server ? or use linux stream editors such as sed or awk to split them in different file.
– Unni
Oct 9 '12 at 12:47
1
no need, he can import all the databases from a single file
– laurent
Oct 9 '12 at 13:01
add a comment |
mysql command to restore sql file is :
mysql DATABASE_NAME < SQL_FILENAME.sql
first make sure that file is sql. Incase it ends with gz file extension, you need to uncompress using command :
gunzip SQL_FILE.sql.gz
mysql command to restore sql file is :
mysql DATABASE_NAME < SQL_FILENAME.sql
first make sure that file is sql. Incase it ends with gz file extension, you need to uncompress using command :
gunzip SQL_FILE.sql.gz
answered Oct 9 '12 at 12:36
UnniUnni
24622
24622
-1 . As I said in the above, there are MULTIPLE databases stored in the file and I want all of them to be restored at once.
– smhnaji
Oct 9 '12 at 12:38
can you export each database separately in phpmyadmin and restore it at source server ? or use linux stream editors such as sed or awk to split them in different file.
– Unni
Oct 9 '12 at 12:47
1
no need, he can import all the databases from a single file
– laurent
Oct 9 '12 at 13:01
add a comment |
-1 . As I said in the above, there are MULTIPLE databases stored in the file and I want all of them to be restored at once.
– smhnaji
Oct 9 '12 at 12:38
can you export each database separately in phpmyadmin and restore it at source server ? or use linux stream editors such as sed or awk to split them in different file.
– Unni
Oct 9 '12 at 12:47
1
no need, he can import all the databases from a single file
– laurent
Oct 9 '12 at 13:01
-1 . As I said in the above, there are MULTIPLE databases stored in the file and I want all of them to be restored at once.
– smhnaji
Oct 9 '12 at 12:38
-1 . As I said in the above, there are MULTIPLE databases stored in the file and I want all of them to be restored at once.
– smhnaji
Oct 9 '12 at 12:38
can you export each database separately in phpmyadmin and restore it at source server ? or use linux stream editors such as sed or awk to split them in different file.
– Unni
Oct 9 '12 at 12:47
can you export each database separately in phpmyadmin and restore it at source server ? or use linux stream editors such as sed or awk to split them in different file.
– Unni
Oct 9 '12 at 12:47
1
1
no need, he can import all the databases from a single file
– laurent
Oct 9 '12 at 13:01
no need, he can import all the databases from a single file
– laurent
Oct 9 '12 at 13:01
add a comment |
You may restore databases with the help of sql 2005 repair database
http://www.sqlserverrepairtoolbox.com repairs data types, views, procedures, tables, keys, indexes and other objects
This does not answer the original question. SQL Server Repair Toolbox is a proprietary Windows program that does not work from the Ubuntu command line.
– karel
4 hours ago
add a comment |
You may restore databases with the help of sql 2005 repair database
http://www.sqlserverrepairtoolbox.com repairs data types, views, procedures, tables, keys, indexes and other objects
This does not answer the original question. SQL Server Repair Toolbox is a proprietary Windows program that does not work from the Ubuntu command line.
– karel
4 hours ago
add a comment |
You may restore databases with the help of sql 2005 repair database
http://www.sqlserverrepairtoolbox.com repairs data types, views, procedures, tables, keys, indexes and other objects
You may restore databases with the help of sql 2005 repair database
http://www.sqlserverrepairtoolbox.com repairs data types, views, procedures, tables, keys, indexes and other objects
answered Apr 6 '13 at 14:19
jerome47_firshteinjerome47_firshtein
1
1
This does not answer the original question. SQL Server Repair Toolbox is a proprietary Windows program that does not work from the Ubuntu command line.
– karel
4 hours ago
add a comment |
This does not answer the original question. SQL Server Repair Toolbox is a proprietary Windows program that does not work from the Ubuntu command line.
– karel
4 hours ago
This does not answer the original question. SQL Server Repair Toolbox is a proprietary Windows program that does not work from the Ubuntu command line.
– karel
4 hours ago
This does not answer the original question. SQL Server Repair Toolbox is a proprietary Windows program that does not work from the Ubuntu command line.
– karel
4 hours ago
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f198170%2frestoring-multiple-mysql-databases-from-one-file-at-the-command-line%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Did you take a look into the file? It should/could contain commands to create and switch to the databases as needed.
– Tom Regner
Oct 9 '12 at 12:42
Yes, databases are created and then they have been selected using
USE database_name
command.– smhnaji
Oct 9 '12 at 12:45
Then Unni and laurents answers are correct.
– Tom Regner
Oct 9 '12 at 13:14