[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 243
  • Last Modified:

SQL, MySQL, 5.0 - I have a notepad file that came with SQL code that creates tables, values and such. How do I insert the code into the database?

The program I just installed came with a file with SQL code inside that creates tables and values and needs to insert into a database. The problem is I don't know the command in which to do so. The database is already created and running. I have the SQL command line and the MySQL Administrator program. Thanks.
0
diffuser87
Asked:
diffuser87
  • 3
  • 2
  • 2
2 Solutions
 
hieloCommented:
try:
mysql -u<user_name> -p<password> < mysql.sql
0
 
hieloCommented:
You would need to provide the username and password of course. To clarify further, consider this:
mysql -uroot -psecret < mysqlCommandFile.sql
0
 
rjgonzaleCommented:
If the SQL script does not create the database you need to run

mysqladmin -u root -ppassword create database
mysql -u root -ppassword database < file.sql

Change "password" with your root password for MySQL and "database" with your database name and of course, file.sql with the name of the file you have
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

 
diffuser87Author Commented:
Still having issues with it. I typed the commands suggested into the MySQL command window. I have attached a picture to try to help you guys figure out what I am doing wrong.... I'm sure it is something simple. Is there any special folder I need to put the .sql file in?
missing-something.jpg.JPG
0
 
hieloCommented:
>> Is there any special folder I need to put the .sql file in
Provide the full path to the location of the file. EX:
mysql -uroot -psecret < "C:\Test\mysqlCommandFile.sql"
0
 
rjgonzaleCommented:
Both are DOS commands and not SQL commands...so...

1 - forget mysqladmin cause you already have the DB created.
2 - in DOS, considering that your DB is called asm and your file mysql.sql ...

cd to directory where mysql.sql is

mysql -u root -p asm < mysql.sql

0
 
diffuser87Author Commented:
Thank you both!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now