DelphiFAQ Home Search:

How to run a *.sql script (mysql)

 

commentsThis article has not been rated yet. After reading, feel free to leave comments and 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-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-08-15, 01:40:15
anonymous from Philippines  
what should i do? i want to export data into txt files directly came from databases using the prompt command.
2008-08-15, 03:15:15
anonymous from Philippines  
to: faceless_terror@yahoo.com
try to use this sql command. coz this is the one i used the time i ask help

mysql>source d:/my documents/run.sql;
2008-09-19, 23:22:22
anonymous from India  
hi,

I have similar problem. I have a .sql script with 'Create database' command. Now when I am using mysql>source c:\mysql\test.sql it works.

But now I wish to run this from my vb6 program whithout any password promp.

pl. help me.
2008-11-19, 22:58:26   (updated: 2008-11-19, 23:09:12)
[hidden] from Jakarta, Indonesia  
try this:
<path to mysql> -h <host> -u <username> -D <database name> --password=<password> < <path to sql file>



--------------------------------------
http://anggapc.blogspot.com
2009-01-09, 16:35:19
anonymous from United States  
And if you want to redirect the output to an external file:

mysql -h <host> -u <username> -D <database name> --password=<password> < /tmp/query.sql >> /tmp/results.sql
2009-05-18, 02:43:41
anonymous  
Hi

i have below SQL file. How i should run this scripts?
Thanks,


-- MySQL dump 10.10
--
-- Host: lldb Database: SPLICE_JAN06
-- ------------------------------------------------------
-- Server version     5.0.22-log

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `skipped_exons_aedes1`
--

DROP TABLE IF EXISTS `skipped_exons_aedes1`;
CREATE TABLE `skipped_exons_aedes1` (
`skip_id` int(11) NOT NULL default '0',
`cluster_id` varchar(12) NOT NULL default '',
`skip_start` int(11) default NULL,
`skip_end` int(11) default NULL,
`exon_id` int(11) NOT NULL default '0',
`ug_id` varchar(20) default NULL,
`exon_start` int(11) default NULL,
`exon_end` int(11) default NULL,
KEY `skip_id` (`skip_id`),
KEY `cluster_id` (`cluster_id`),
KEY `exon_id` (`exon_id`)
) TYPE=MyISAM MAX_ROWS=1000000000 AVG_ROW_LENGTH=100000;

--
-- Dumping data for table `skipped_exons_aedes1`
--


/*!40000 ALTER TABLE `skipped_exons_aedes1` DISABLE KEYS */;
LOCK TABLES `skipped_exons_aedes1` WRITE;
INSERT INTO `skipped_exons_aedes1` VALUES (1,'Aae.5489',2547,19553,663,'Aae#S27615898',19319,19501),(2,'Aae.3247',2254,2605,896,'Aae#S28782111',2317,2494),(3,'Aae.12862',2793,3083,1102,'Aae#S27626165',2954,3010),(4,'Aae.9672',2118,6800,73,'Aae#S27625996',2454,2625),(4,'Aae.9672',2118,6800,74,'Aae#S27625996',2689,2822),(5,'Aae.6224',2390,3536,505,'Aae#S27639602',3076,3141),(6,'Aae.4933',13934,90712,728,'Aae#S28790890',90507,90557),(7,'Aae.4094',12560,47359,789,'Aae#S28818687',46396,46508),(7,'Aae.4094',12560,47359,790,'Aae#S28818687',46814,46937),(8,'Aae.2782',17635,26189,988,'Aae#S27681901',26002,26123),(9,'Aae.2552',7683,9305,1007,'Aae#S27631275',8211,8459),(10,'Aae.12202',35107,36912,1212,'Aae#S28782729',35831,35851),(11,'Aae.10735',10609,21274,1448,'Aae#S27643441',20933,21088),(12,'Aae.10',9731,14589,1590,'Aae#S28800653',13824,13898);
UNLOCK TABLES;
/*!40000 ALTER TABLE `skipped_exons_aedes1` ENABLE KEYS */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

2009-06-02, 06:46:19
anonymous from India  
Thanks for the Info

 

 

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.
 

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:
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.