Is there any way I can Import a huge database into my local server.
The database is of 1.9GB and importing it into my local is causing me a lot of problems.
I have tried sql dumping and was not successful in getting it in my local and have also tried changing the Php.ini settings.
Please let me know if there is any other way of getting this done.
I have used BigDump and also Sql Dump Splitter but I am still to able to find a solution
mysql -u #username# -p #database# < #dump_file#
Navigate to your mysql bin directory and login to your mysql
Select the database
use source command to import the data
[user#localhost] mysql -uroot -hlocalhost // assuming no password
[user#localhost] use mydb // mydb is the databasename
[user#localhost] source /home/user/datadump.sql
Restoring a backup of that size is going to take a long time. There's some great advice here: http://vitobotta.com/smarter-faster-backups-restores-mysql-databases-with-mysqldump/ which essentially gives you some additional options you can use to speed up both the initial backup and the subsequent restore.
Related
I'm using phpmyadmin to export one of my database.
And it was huge ( larger than 1 GiB )
And export procedure ended because of the PHP had run 360 seconds ( maxmium execution time ) and was killed while I thought that the backup file was correct and complete.
Later, I want a rollback.
I drop the old database.
And I import the backup sql file.
And
My data are partially lost.
Why phpmyadmin doesn't notice me???
I'm really ******* angry.
For databases huge like that phpMyAdmin is not the best solution. Better use shell command to dump/import database. Under linux (most likely you are on linux)
mysqldump -u username -p database_name > dump_file_name.sql
Copy it, i.e. with FTP to other server and then import like:
mysql -u username -p database_name < dump_file_name.sql
After "-p" you can immediately put your password, but you can also skip it and you'll be asked to enter it.
I have a 28 MB sql file need to import to mysql.
Firstly, i'm using xampp to import, and it fails, and so i change my max_file_uploads, post_size(something like that)in php.ini-development and php.ini-product to 40 MB, but it still show "max:2048kb" and import fail again.
From research, i've learned to import by using mysql.exe, so i open mysql.exe and type the command line(msdos) below:
-u root -p dbname < C:\xxx\xxx\sqlfile.sql
but still failed again and again.....
what the problem is? xampp? or my sql setting?
Try this:
mysql -uroot -p --max_allowed_packet=24M dbname
Once you log into the database:
source C:\xxx\xxx\sqlfile.sql
I think that you should be able to load your file
How large is your file?. You might as well do it from a console:
mysql -u##USER## -p ##YOUR_DATABASE## < ##PATH_TO_YOUR_FILE##
Do that without executing your mysql.ext file: just "cd" right into the directory and try the command.
It will ask for your password and start importing right away. Don't forget to create the database or delete all tables if it's already there.
I always found this approach quick, painless and easier that rolling around with php directives, phpmyadmin configuration or external applications. It's right there, built into the mysql core.
You should increase max_allowed_packet in MySQL.
Just execute this command before importing your file:
set global max_allowed_packet=1000000000;
I also fetched the similar problem. So after that I also conclude , large sql file will never be imported to mysql. It will always give timeout error.
Then I found a solution.
There is an software Heidisql.
follow below steps:-
1) download the software.
2) then install the software
3) create new session in Heidisql and open the session
4) then go to Tools -> Load SQL File -> Browse.
That's it. This solution works best for me.
check the link here
I found the only solution was to log in to MySQL from the command line and use the 'source' command:-
1) cd to the directory containing your SQL file for import, then log into MySQL:
#> mysql -u YOURUSERNAME -p -h localhost
2) use MySQL commands to import the data:
#> use NAMEOFYOURDB;
#> source NAMEOFFILETOIMPORT.sql
This also feeds back info about progress to your terminal, which is reassuring.
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.
I'm using a php script to backup my sql databases remotely that utilizes mysqldump. http://www.dagondesign.com/files/backup_dbs.txt
and I tried to add the the --lock-tables=false since I'm using MyISAM tables but still got an error.
exec( "$MYSQL_PATH/mysqldump --lock-tables=false $db_auth --opt $db 2>&1 >$BACKUP_TEMP/$db.sql", $output, $res);
error:
mysqldump: Couldn't execute 'show fields from `advisory_info`': Can't create/write to file 'E:\tmp\#sql_59c_0.MYD' (Errcode: 17) (1)
Someone told me this file was the lock file it self and I was able to find it in my Server that I wanted to backup.
So is this the lock file? And does it lock the database if you do remotely no matter if I put the variable --lock-tables=false? Or should it not be there since there are a lot of people working on the server and someone might have created it?
It's likely --lock-tables=false isn't doing what you think it's doing. Since you're passing --lock-tables, it's probably assuming you do want to lock the tables (even though this is the default), so it's locking them. In Linux, we don't prevent flags but appending something like =false or =0, but normally by having a --skip-X or --no-X.
You might want to try --skip-opt:
--skip-opt Disable --opt. Disables --add-drop-table, --add-locks,
--lock-tables, --set-charset, and --disable-keys.
Because --opt is enabled by default, you can --skip-opt then add back any flags you want.
On Windows 7 using Wamp, the option is --skip-lock-tables
Took from this answer
I'm moving a site that had access to phpmyadmin to one where I don't (not yet anyway). Is there a php script to import the generated .sql file into a database? The db is created and ready, just need to import the tables and records.
Try this.
Upload your SQL file to the web space via FTP and execute a page with this code in it.
<?php
$file="path/to/file.sql";
$command = "mysql -u $dbuser --password='$dbpassword' --host='$sqlhost' $dbname < $file";
exec($command);
?>
Don't forget to set the variables for database name, username, and password. Also, make sure PHP has access to execute commands using the exec function.
Why use php, why not use MySQL itself:
http://dev.mysql.com/doc/refman/5.5/en/mysql.html
Use SSH. Install PuTTy first. Ask your host the server IP, username and password for SSH server, and then do the work. Anyway, how do you think you are going to properly manage your tables and databases without phpmyadmin or any other alternative SQL client, eh? Ask your hosts to install them. Btw, looks like your host's at Antarctica or some other ancient place. I mean, come on man, a SQL client like phpMyAdmin is offered even in free subhosting.