DelphiFAQ Home Search:

How to run a *.sql script (mysql)

 

comments7 comments. Current rating: 5 stars (1 votes). Leave comments and/ or rate it.

Question:

I am installing a .php based tool, and one of the final instructions is to "Run the mysql.sql script to create the necessary tables in the database.". How to I achieve this?

Answer:

The *.sql file is a text file with SQL statements to be executed by the mysql server.

You can run it through a tool like phpMyAdmin - just open a query window there and copy and paste the content of that text file in there. phpMyAdmin and possibly other frontends will also allow to upload a *.sql file through the web browser. In phpMyAdmin click on the SQL tab.

If you don't have any such front end installed, you can also go to the shell (assuming you're on a Linux box here). If your site is hosted somewhere, you'll need putty (or a similar tool) to connect to the server.

Ftp your *.sql file to the (remote) machine if not done yet.

Execute this command and you'll be fine:

mysql <my_db_name> -u<user_name> -p<password> <mysql.sql


Comments:

2007-02-06, 05:20:57
anonymous from India  
u can also achieve that by using the following in mysql command prompt
mysql>source scriptname.sql
2007-10-24, 21:29:46
anonymous from Philippines  
Hi,
thanks,

mysql <my_db_name> -u<user_name> -p<password> <mysql.sql

worked for me.

regards,
rhani
2008-03-06, 02:25:08
faceless_terror@yahoo.com from Philippines  
rating
i've already put the content of the text file on the query tab.
and then i typed in the mysql console the command:
mysql>@ mysql.sql;

it's error.
i need some help.tnx anyway.
2008-03-12, 14:55:26
Asad from United States  
Using this argument mysql assumes that the mysql database is on the same server but if u want to connect to a remote server don't forget to add -hSERVERADDRESS to the arguments
2008-03-16, 01:12:38
anonymous from Philippines  
oh ok.tnx for your help!!
anyway, i've found a way of executing that by this command:
mysql>source d:/my documents/run.sql;
where d:/my documents/run.sql is the path where the script is located.
2008-03-16, 01:15:47
anonymous from Philippines  
hi to all!! i have another problem again in mysql...
could you help me coz i want to create a report using mysql with respective codes that allows me to add title of the report,sum up a row and many more.
2008-04-20, 23:49:39
anonymous from Philippines  
I have problem regards in executing the password of mysql plllllllllsssssssssssss help me guys::::Tnx lol


Keywords:

 

 

Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option.
 
It seems that you are
from Washington, US .

Info/ Feedback on this

Show city and country
Show country only
Hide my location
Leave your comment here:
Please type in the code:
photo Add a picture:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity. The owner of this web site reserves the right to delete such material.