• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1033
  • Last Modified:

How Do I Run A Create SQL Script for MySQL?

Does anyone have any simple instructions on setting up a pre-prepared MySQL Database? The instructions given were:

"The database can be created from the command line using the createdb.sql script. Alternatively the schema.sql and data.sql scripts can be imported individually (in that order)."

If someone could post some easy instructions on doing both you can have the points. There is currently no database setup on the hosting space.
0
AndoverIT
Asked:
AndoverIT
  • 2
  • 2
2 Solutions
 
BioICommented:
I guess something like this:
1) go to the directory where your msyql-executable is located
2)  mysqladmin -u root -pyourpassword -h servername create yourdatabasename
3)  mysql -u root -pyourpassword -h servername yourdatabasename < createdb.sql

do you have root acces to create a database?
0
 
AndoverITAuthor Commented:
Yes I do - will give it a try and get back asap.
0
 
ll_jaxnCommented:
Dont forget...

You will still need to execute the SQL commands in the Scheme and Data files.
The command
 mysql -u root -pyourpassword -h servername yourdatabasename < createdb.sql

might need a -d in front of yourdatabase, it is easy to figure out....just enter  mysql --help on the command line and it will explain the - parameters.  
The < is a pipe, this tells the operating system to send the contents of the file named to the standard input device (STDIN or CON) associated with the program mysql....basically MySql thinks you are typing in the commands.

So do the same command
mysql -u root -pyourpassword -h servername yourdatabasename < createdb.sql
with
mysql -u root -pyourpassword -h servername yourdatabasename < scheme.sql
mysql -u root -pyourpassword -h servername yourdatabasename < data.sql

Oh...FYI...Scheme is the term for Definition, a scheme defines the table struncture and relationships, the data.sql is most likely a bunch of SQL insert commands.
0
 
BioICommented:
no, I don't think you have to run to import these scheme.sql and data.sql.

Because the createdb.sql contains - I assume - also the create and insert statements etc. Because the text provided by AndoverIT clearly mentiones: "***Alternatively*** the schema.sql and data.sql scripts can be imported individually (in that order)." This is just a intermediate solution if you have NOT root acces and thus cannot create database, but since by AndoverIT has root access, it will not be necessary, and importing the createdb.sql will be enough.

Running importing scheme.sql and data.sql will only result in a lot of errors!
0
 
AndoverITAuthor Commented:
Thanks guys - am going to run it later today and hopefully confirm poits afterwards.

Thanks in the meantime
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

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