0

im having a mysql database which around 300mb but unfortunately i cant import this file to my web host using phpmyadmin and i dont have shell access.

i tried the below alternatives

MySQLDumper

bigdump

but could get it inserted to the database.

The database has been uploaded to a folder in .sql format. is it possible to create a php script to read the .sql file and execute the queries?

the sql file was dumped using mysqldump.

below is the format. (please not that i have removed some lines coz there are so many)

DROP TABLE IF EXISTS `prime_lands`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `hotels` (
  `hotel_id` int(11) DEFAULT NULL,
  `chain_id` int(11) DEFAULT NULL,
  `chain_name` varchar(100) DEFAULT NULL,
  `brand_id` int(11) DEFAULT NULL,
  `brand_name` varchar(100) DEFAULT NULL,
  `hotel_name` varchar(100) DEFAULT NULL,
  `hotel_formerly_name` varchar(100) DEFAULT NULL,
  `hotel_translated_name` varchar(100) DEFAULT NULL
...........
)

-- Dumping data for table `prime_lands`
--

LOCK TABLES `prime_lands` WRITE;
/*!40000 ALTER TABLE `prime_lands` DISABLE KEYS */;

INSERT INTO `prime_lands` VALUES (1,421,'Samed Resorts Group',921,'Samed Resorts Group','Sai Kaew Beach Resort','','Sai Kaew Beach Resort',.......................)

....................................
2
  • Most likely, can you provide a simple of the format of the sql file? Was it created with mysqldump? Is it just a file of queries? Commented Dec 5, 2012 at 19:06
  • @Paronity its a mysqldump.. i have added the sample code.. Commented Dec 5, 2012 at 19:20

1 Answer 1

2

should work:

$run=   exec ('mysql -u username -p password database_name < filename.sql ', $out);
var_dump($run);
var_dump($out);

May be better for debugging:

$out = shell_exec('mysql -u username -p password database_name < filename.sql');
var_dump($out);

as a one off you may be able to ask your host to run the command for you, most 'nice' hosts would help you out with this.

Sign up to request clarification or add additional context in comments.

3 Comments

i tried that but didnt work. i contacted my hosting godaddy bt they keep on sending a guide on how to import using phpmyadmin, which doesnt work for me.
what error did you get back? go-daddy is the worst host on the planet- so easy answer - move.
@Dragon when i run the first code i get this note "default-auth (No default value)"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.