473,503 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Importing a database

61 New Member
I just managed to use mysqldump to dump a database into a text file. Now I uploaded it into my server where i want to import it.

I tried looking up in google and came up with this command:

mysql -p --user=web16u1 < workready.txt
where web16u1 is my databse username and workready.txt is the file that contains all the CREATE TABLE stuff as output of mysqldump command.

I got the following error:
-bash-3.2$ mysql -p --user=web16u1 < workready.txt
Enter password:
ERROR 1046 (3D000) at line 22: No database selected
I can easily see the problem but how do I modify the command to make it include the database name?
Sep 28 '08 #1
2 12126
coolsti
310 Contributor
I just managed to use mysqldump to dump a database into a text file. Now I uploaded it into my server where i want to import it.

I tried looking up in google and came up with this command:



where web16u1 is my databse username and workready.txt is the file that contains all the CREATE TABLE stuff as output of mysqldump command.

I got the following error:


I can easily see the problem but how do I modify the command to make it include the database name?
You could do this two ways.

One is just to add the database name to the command line mysql command:
Expand|Select|Wrap|Line Numbers
  1. mysql -p --user=web16u1 databasename < workready.txt
  2.  
Of course, substitute the word "databasename" with the name of the database.

What I usually do is to edit the mysqldump file, in your case workready.txt, and add the following line just before the first statement that tries to do anything to your database:

Expand|Select|Wrap|Line Numbers
  1. use databasename;
  2.  
Again substitute your database name with the word "databasename". This is just a simple statement to change the current database.
Sep 29 '08 #2
tomarvijay80
10 New Member
u can use source workready.txt /*(if your file is in the same directory otherwise give path before workready.txt)*/

It will drop database and create a new one, if u don't want to drop and create a database simply open ur .txt file and remove drop and create database statement.
Oct 6 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
8687
by: Andreas Emmert | last post by:
Hi there, I'm trying to import a csv file into my MySQL database. Unfortunately the number format for the price column is formatted in German style, i.e. XX,XX (decimals separated by comma not...
2
1991
by: TheElectron707 | last post by:
Hi! I have a scenario in which i am importing a VERY LARGE database over the network. (Linking is not my solution). Now it takes many hours to import the complete database. I want that once the...
9
4016
by: Edward S | last post by:
I budget for a Project in an Excel sheet as illustrated below. The months below are usually a 2 year period i.e. 24 months, though it could be over 24 months depending upon a Project. I then...
1
3648
by: sparks | last post by:
I have never done this and wanted to ask people who have what is the best way. One person said import it to excel, then import it into access table. but since this will be done a lot, I am...
3
1802
by: Mark | last post by:
All, As you can see below, I have had problems with inquisitive souls looking at data they shouldn't be. I though disabling the ability to create new databases using my workgroup would stop this...
5
3152
by: dixie | last post by:
If I sent a user an empty database container - dB with no tables and I needed them to import their tables into it and one of their tables was a hidden table with the prefix Usys, is there any way...
2
3159
by: Snozz | last post by:
The short of it: If you needed to import a CSV file of a certain structure on a regular basis(say 32 csv files, each to one a table in 32 databases), what would be your first instinct on how to...
12
6184
by: JMO | last post by:
I can import a csv file with no problem. I can also add columns to the datagrid upon import. I want to be able to start importing at the 3rd row. This will pick up the headers necessary for the...
1
1882
by: Phil | last post by:
I want to add a button to a form to import a text delimited file. The File is delimited by "^" and so I have created a specification file by manually impoting the text file, using the advanced...
1
3208
by: aconti74 | last post by:
Hello I am new to vba programming/coding. I am writing a program that goes through a directory of text files and imports them into the database. The problem is eventually the database gets to big...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7084
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7278
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7328
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5013
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.