Here is a long story short. I'm trying to write a tool that copies files and a database from one of our domains to another, we have multiple domains that represent various stages of development. One is www (that's our live domain), then we have a dev domain, a design domain and finally a live-test domain. I'm trying to build this tool using as many pre-existing solutions as possible (normally I try to write everything in PHP, now I'm trying to run native command line programs from PHP instead).
The issue I'm having is that I can't seem to import an sql back up correctly into a database.
Here is what I am doing.
I ssh into the VPS server and issue this command:
email@example.com [~/tmp]# mysqldump -h localhost -u admin_dev -ppassword admin_clr_test > /home/admin/tmp/test.sql
It works as expected, it creates a file called test.sql in the directory /home/admin/tmp.
Then I use PHPMYADMIN from the web to delete every table out of the database 'admin_clr_test', it works as expected.
Then I try to IMPORT that very same test.sql file back into the same database that created it previously.
I do this command:
firstname.lastname@example.org [~/tmp]# mysqldump -h localhost -u admin_dev -ppassword admin_clr_test < /home/admin/tmp/test.sql
And these are the results I get:
-- MySQL dump 10.11
-- Host: localhost Database: admin_clr_test
-- Server version 5.0.96-community
/*!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 */;
/*!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 */;
-- Dump completed on 2012-12-21 6:28:44
And that's it, it doesn't import anything into the database (I check with PHPMYADMIN). It doesn't throw an error message, it just spits that out to the console and gives me a new prompt. Is this is a very bizarre problem? I have tried manually uploading the test.sql file into PHPMYADMIN to do a restore and it works fine. But for some reason it will not import from the command line nor does it give me an error message I can work with.
I'm totally baffled and just feel like tearing my hair out with this. Any ideas? I will also be contacting my VPS hosting solution to troubleshoot the issue in case it has something to do with the system itself.
I figured it out. Apparently you have to use "mysql" from the command line and not "mysqldump" to import. That seems obvious but I could have sworn there were multiple guides on the net telling me that that was how you did this.