Welcome to WebmasterWorld Guest from

Forum Moderators: phranque

Message Too Old, No Replies

some simple database questions

database help

11:12 pm on Mar 6, 2003 (gmt 0)

New User

10+ Year Member

joined:Jan 5, 2002
votes: 0

I've set up a MYSQL database on my local machine as a part of a prefabricated ecommerce website that includes a database and table data. I am trying to populate the tables in the database with a completed file called DB.sql that is located in the C: directory. I can't seem to write the line of code that performs this function because I can't get a C: prompt (I can only get a C:\>). My question is how do I enter the following line of code:

C: type DB.sql ¦ mysql -h localhost -u root flashDB

As well, is there some sort of rule of thumb as to where to upload a MYSQL database on a server...is this a question for my hosting company?

2:04 am on Mar 8, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Sept 21, 1999
votes: 0

I have very limited database experience but your first question seems more related to the op system. What I mean is that "C:" refers to a drive under most MS op systems. "C:\" refers to the root directory of the C drive. If your database is in the root directory of C: then your command needs to reflect that:
C:\ type DB.sql mysql -h localhost -u root flashDB

If it's in a different directory, include a full path:
C:\Dir1\Dir2\ type DB.sql mysql -h localhost -u root flashDB

I didn't attempt to analyze the remainder of your command and don't plan to, but it doesn't look right to me. I work with this stuff far too seldom and would need to "hit the books." Perhaps someone else will add their comments. You may need to "hit the books" too.

If you're buying commercial hosting, my experience is they take pains to make direct access to database files impossible, for security reasons. Ask your hosting company how they prefer to handle populating a database.

2:28 am on Mar 8, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:July 16, 2001
votes: 4


[edited by: sun818 at 3:13 am (utc) on Mar. 8, 2003]

2:53 am on Mar 8, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Apr 18, 2002
votes: 0

Try this:

First, make sure that you are connecting to the mysql query processor. From your command line, try just: "mysql -h localhost -u root flashDB"

If all is good, you will be rewarded with the "mysql>" prompt (probably after entering the password for user root). If this works, then you are accessing mysql correctly. You can just "exit" to return to the command prompt.

The "-h localhost" identifies the server you want to connect to. It looks like the server is on the machine you are working on (localhost).

The "-u root" identifies your user id as "root". This should give you god-like powers in mySql.

The "flashDB" is the name of the database you have established in mySql.

Next, make sure you have access to the file DB.sql, which probably contains commands to create tables and other objects in the database for you.

You can test that you have access to DB.sql by just executing "type DB.sql" (or "cat DB.sql" - depending on your operating system). The response that should be to send the contents of DB.sql to the standard output (your screen).

If you have all that together, you are good to go with the command you entered.

the pipe "" is an operating system tool to send the standard output of one command (like "type DB.sql" into the standard input of another program (like typing it into mysql).

Another way to do the same thing is to enter mysql with:

C:\>mysql -h localhost -u root flashDB

and then using the mysql source command to execute the contents of the file:

mysql>source DB.sql

Then, you can exit mysql with:


Also, this may be useful:


The "type DB.sql" is an operating system command to send the contents of the file DB.sql