0

hello guys i make a database software and i want to import sql file into mySQL database with query , so that when user click button this sql file is auto import , Is there any way to do this , thankx

3
Contributors
4
Replies
21
Views
1 Year
Discussion Span
Last Post by basit_3
0

If the sql files is a list of INSERT, SELECTS, etc, read the file via a stream reader and execute each line as a standard query i.e. the text in each line becomes the string that makes up the command text.
Alternatively, you can execute a command line process with something similar to this:
"C:\Program Files (x86)\MySQL\MySQL Server 5.0\bin\mysql.exe" -C -B --password=[password] -P 3306 --user=[username] --host=localhost --database=[database] -e "\. C:\Backups\Mybackup.sql"

That came from this SO article: http://stackoverflow.com/questions/13648523/how-to-import-large-sql-file-using-mysql-exe-through-streamreader-standardinp. Most the command should be obvious and the -e bit is the important part, it points to the file you want to execute.

0

this sql file not containing insert or select string
actually this contain

/*!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 ` b2`
--

DROP TABLE IF EXISTS ` b2`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE ` b2` (
  `Dealer_Name` varchar(30) NOT NULL,
  `Bill` int(11) NOT NULL DEFAULT '0',
  `Payment` int(11) DEFAULT '0',
  `Dues` int(11) NOT NULL DEFAULT '0',
  `Comment` varchar(45) DEFAULT 'Nothing',
  PRIMARY KEY (`Dealer_Name`),
  UNIQUE KEY `Bill_UNIQUE` (`Bill`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

like that characters

Edited by basit_3

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.