DelphiFAQ Home Search:

How to run a *.sql script (mysql)

 

comments28 comments. Current rating: 2 stars (4 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:

You are on page 1 of 2, other pages: [1] 2
2009-09-30, 10:33:26
anonymous from United States  
TO_CHAR(
CASE TO_CHAR(LAST_DAY(TRUNC(SYSDATE)),'d')
WHEN '1' THEN LAST_DAY(TRUNC(SYSDATE))-2
WHEN '7' THEN LAST_DAY(TRUNC(SYSDATE))-1
ELSE LAST_DAY(TRUNC(SYSDATE))
END, 'DD-MON-YYYY') last_weekdate
2009-11-24, 03:04:43
anonymous from United Kingdom  
Hi,
You can use following commands at your mysql> prompt:

mysql> source file_name.sql
or
mysql> \. file_name.sql

of course you must either select database in the .sql file or you must 'use' the database first before running a script.

Regards
2010-03-28, 09:14:58
anonymous  
CREATE TABLE `users` (
`id` int(3) NOT NULL auto_increment,
`login` varchar(8) default NULL,
`password` varchar(8) default NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=3 ;
2010-03-31, 21:24:21
anonymous from Bangladesh  
how to find if the attribute contains any value by sql querry
2010-04-22, 11:25:58
from Sri Lanka  
eeeeeeeeeeeeee
You are on page 1 of 2, other pages: [1] 2

 

 

NEW: Optional: Register   Login
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, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

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.

photo Add a picture: