I have a large sql file < 600 MB.
This files is backup for forum and I want to upload it to empty db.
How I can upload it??
I can't use PHPMyAdmin? and I used BigDump and it doesn't insert all tables.
How to do it?? Is there any other way?
Thanks
EDIT : I don't have access to command line, I just have my CPanel
Try the command line. Must be something like:
mysql --user=name --password=pw < mysql_db_dump.sql
This is usually done from the command line like this:
mysql -hhostname -uusername -ppassword < bigfile.sql
Make sure you create your database first and that the user has CREATE TABLE privileges such as the root user.
use mysql command line
you can see more details in this link
Related
I've got a problem with my mysql server. Basically I cannot upload my database... I tried already :
mysql -u username -p database_name > file.sql
mysqldump -p -u username database_name > dbname.sql
Nothing works... first method stuck after i insert password to mysql server and second method did nothing, after mysqldumb nothing happed...
Also I tried to use phpmyadmin, but durring uploading after 13s I get blank screen, with no error. I setup memory_limit and upload_max_filesize to 128M but still getting this problem.
Thanks
You can upload sql files using .rar or zip folder. via phpmyadmin in this case you will have compressed the file size and you shouldn't face that issue again.
You want to read from the sql file, not write to it.
Use < not > for the first line.
You may have to get a clean copy of file.sql as you've probably overwritten it.
(The second line is for copying the database into a file, not the other way around)
The first command is only for connecting to the database. You are not seeing anything because all the output is being directed to file.sql. Try removing the > file.sql from the command and you should see errors or the sql prompt.
The second command "looks" ok, assuming you want to save data TO the file, not load data FROM the file.
To load data, use
mysql -h hostname -u user --password=password databasename < filename
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 need PHP code to convert the database. I tried How to convert mysql to SQLite using PHP but it dint have answer
I finally found its solution.
Save sh file available at
https://gist.github.com/943776
and execute
"./mysql2sqlite.sh DBNAME --databases DBNAME -u DB_USERNAME -pDB_PASSWORD | sqlite3 database.sqlite"(without qoutes and with "`")
in php file.
Save both files in one folder
Go to phpmyadmin
click export database
download as sql file.
Download it....
go to your sql lite management software
import the .sql file
done...
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.