?
Solved

How to load a table in to the database.

Posted on 2008-11-05
6
Medium Priority
?
383 Views
Last Modified: 2012-06-27
Dear Experts,
I have created simple_table.sql in text pad and store it in C:\wamp\bin\mysql\mysql5.0.51b\data\project\simple_table.sql .. But when I try to run it through "source \project\simple_table.sql" it does not want to load it...
Can you tell me how to load this file, please?
create table simple_table (
last_name varchar(30),
postcode char(8)
);

Open in new window

0
Comment
Question by:Cihla
  • 3
  • 2
6 Comments
 

Accepted Solution

by:
saifulbahri earned 260 total points
ID: 22887050
Do you use the mysql command line client? If so i suggest you go into directory C:\wamp\bin\mysql\mysql5.0.51b\data\project\ and then start the mysql client.

 cd C:\wamp\bin\mysql\mysql5.0.51b\data\project
 mysql -h xxx -u xxx -p
 mysql > use database
 mysql > \. simple_table.sql
0
 
LVL 26

Expert Comment

by:Umesh
ID: 22887068
what is the error you are getting???/

I just tried it and its working for me..
E:\MySQLMaster\bin>mysql -u root -p
Enter password: ***
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
 
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
 
mysql> use test;
Database changed
mysql> source e:/test.sql
Query OK, 0 rows affected (0.02 sec)
 
mysql> desc simple_table;
+-----------+-------------+------+-----+---------+-------+
| Field     | Type        | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| last_name | varchar(30) | YES  |     | NULL    |       |
| postcode  | char(8)     | YES  |     | NULL    |       |
+-----------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
 
mysql>

Open in new window

0
 
LVL 26

Assisted Solution

by:Umesh
Umesh earned 240 total points
ID: 22887094
>>source \project\simple_table.sql

You should pass complete path to source file...

mysql>source C:\wamp\bin\mysql\mysql5.0.51b\data\project\simple_table.sql;

Also you can do this... from command line.. CD to mysql/bin

mysql -uusername -ppassword DBNAME < C:\wamp\bin\mysql\mysql5.0.51b\data\project\simple_table.sql
0
Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

 
LVL 26

Expert Comment

by:Umesh
ID: 22937420
Did you try?
0
 

Author Closing Comment

by:Cihla
ID: 31513552
Hi, sorry for taking a time to reply but was quite busy..
0
 

Author Comment

by:Cihla
ID: 23022447
I just forgot to to "use database" and then use the "source".
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month15 days, 13 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question