I've one 'xyz.sql' dump file uploaded in 'test' folder on the server.
Created a blank database called 'dummy' in MySQL database using PHPMyAdmin.
Then I logged into the server using ssh and run the following command, it gave me no error but the database is not getting imported.
mysqldump -uroot -pxyz123 new_db > xyz.sql
The username I use to login to the PHPMyAdmin is root and password is xyz123. The blank database I created is 'new_db', the file which I want to import is xyz.sql.
You can see in above command I've used these details.
Try using < instead of > when you import the dump. First check if xyz.sql still contains your dump!
Related
I am trying to import some .sql file (which contains my database) into xampp mysql database but no luck.
Here is my attempts :
step-1: I Entered into c:\xampp\mysql\bin>
step-2: And then used this command for import my sql file to my local database (I placed 'raj-db.sql' in 'c:\xampp\mysql\bin>' folder).
Step-3: After click on enter it is asking 'Enter password:' and immediately going to 'c:\xampp\mysql\bin>' path with out enter any password.
Please can you help me on this.I installed fresh xampp also but still behaving the same.
It is coming like this
c:\xampp\mysql\bin>mysql -u root -p my-db-name < file-name.sql
Enter password:
c:\xampp\mysql\bin>
If I run 'c:\xampp\mysql\bin>mysql' it is coming as 'MariaDB [none]>'.But usually it should come like 'mysql>'.
How to Load MySQL Database Dump Using XAMPP
Step 1 : Start your Xampp
Step 2 : Start your MySQL Server (if not already started)
Step 3 : Launch into CLI mode by clicking on the CMD button (black
button).
Step 4 : Copy your Database backup into same directory.
Step 5 : Load the backup into your already created Database using the
following command
mysql -u root -p DatabaseName < DatabaseDump.sql
You may use the attached screenshots as your guide.
Hope this helps.
Does the target database is already created? Import needs it created and empty for it to work.
CREATE DATABASE db-name
If it is already created try this and then import with your command:
use db_name;
I am importing a MySQL database from another server to my own server using phpMyAdmin. But the problem is:
I go into import then choose a file which have extension like .sql, .xml. After this procedure I click on the ok button but this doesn't give any response and doesn't even do anything, the page just remains stable.
I also tried with MySQL command prompt using mysqldump.
mysqldump -u username -p databse > database name
but this is also giving an error.
Can any one please help me in solving this?
This command is used to export :
mysqldump -h hostname -u username -p database > sql_file_name
to import you should use
mysql -h hostname -u username -p database < full_file_path
first you need to export a DB from the first server.
on your server you first need to create a new DB and than do the import.
the DB you imported will go to the DB you just created.
i am using phpmyadmin and i exported the database which I had locally. The exported file has an extension of .sql. I want to import the exported database into a database found online on the server. The server doesnt use phpmyadmin. I already connected to the database using SQL wave software however it doesn't offer the import feature like phpmyadmin does. After i installed mysqldumpler however i have the same problem. I cannot browse and import a .sql file. Can someone tell me how i can import the .sql file into my live database? Maybe a software you know or a command?
Copy the file to server. SSH into the server. Then you can load with the command line client:
mysql -u username -p dbname < path/to/file.sql
You will need to create the DB first.
i already save a backup for all databases in phpmyadmin by about 4.5 MB and gzip format.
but now i want to restore that in phpmyAdmin via import tab. but we know that max allowed size for upload a file is 2,048KiB and when try to upload shown this message error:
No data was received to import. Either no file name was submitted, or the file size exceeded the maximum size permitted by your PHP configuration
i use MySQLDumper script to restore but in this script we can choose only one database to restore while i want to restore all my databases that i had.
how can i do this. i use wamp on windows 8.
You can restore large database using mysqldumper http://www.mysqldumper.net. If you want to restore it on your domain server first you upload sql file using ftp and then restore using mysqldumper
You can bypass having to use phpmyadmin by using the terminal.
You should unzip your mysqldump first.
Get the DOS command prompt by typing "cmd" under Start->Search programs and files.
Navigate to the directory where your mysqldump is, and then type (for single database):
mysql -uusername -ppassword name of database < filename of the mysqldump
If you want to restore all the databases (it seems like you dumped using --all-databases):
mysql -uusername -ppassword --databases name of database name of another database name of yet another database < filename of the mysqldump
Also note that there is no space in between -u and the username, and -p and the password.
All I want to do is create a new database off of a dump created by phpmyadmin.
This dump is located in : /var/www/iadmin/wikifresh/db/template.sql and won't ever change.
I ran this command once, and the database was created fine
mysql test < /var/www/iadmin/wikifresh/db/template.sql
and it created the database. So, I put that script inside of a php exec command:
(note: $wikiname is the name of the new wiki being created)
$dbwikiname = escapeshellarg($wikiname);
exec("mysql $dbwikiname < /var/www/iadmin/wikifresh/db/template.sql");
now, when this script runs, I get:
ERROR 1049 (42000): Unknown database 'test'
even if I try to run it from my command line I have this issue.
what am I doing wrong?
For mysql to be invoked with a default database name, the database must exist.
Some distributions of MySQL happen to ship with a database called test, which explains why your command succeeded at first. One presumes you have since dropped that database? You will need to recreate it before attempting to select it:
CREATE DATABASE IF NOT EXISTS test;
Of course, you could instead place the above command, followed by USE test; atop your template.sql file and then invoke mysql without specifying a default database.
it seems you don't have the database 'test' created in the MySQL server of that machine, and the template.sql doesn't have the 'CREATE DATABASE' command. So you have to either create it first, or add the 'CREATE DATABASE' to the template.sql