patternphpModerate
importing large SQL file phpmyadmin
Viewed 0 times
filesqlphpmyadminlargeimporting
Problem
I am trying to import this SQL file in phpmyadmin and got this message
What do I do to do this import?
#1064 - You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version
for the right syntax to use near
'
Fatal error: Allowed memory size of 134217728 bytes exhausted (tr' at line 1
What do I do to do this import?
Solution
Assuming you can't further increase the memory size then there are a couple of options.
-
If you aren't familiar with the command line and you really want to stick with a GUI style import then you can use BigDump (http://www.ozerov.de/bigdump/). I used it once but it's been a while. From what I remember you will download a file named bigdump.php (with some instructions) and put it on your webserver in the directory with the MySQL DB dump file that is too large to import via PHPMYADMIN. Then navigate to it using your browser - something like http://your-website.com/bigdump.php.
-
If you are familiar with the command line and using a Linux based system then you can use code like like this:
mysql -u USERNAME -p DATABASENAME
The database and user (with privileges to the database) will need to exist prior to running this command though. Note I copied the above command from another source. I always do my dumps and restores like this:
DUMP:
RESTORE: `gunzip
FTP & RESTORE instructions:
Download FileZilla here: http://filezilla-project.org/download.php?type=client
Typically you can FTP into your server (especially a shared host) using the same login and password you would for SSH (you command line login). Just make sure to set up the connection to your server properly in FileZilla.
Once connected your default path will likely be your $HOME folder (on nix machines). If you aren't planning on doing a lot of FTPing just dump what you want in there. You can always move it from the command line.
If you FTP'd a MySQL Dump into your $HOME folder then the RESTORE command for a DB named mydb and a db dump file named mydb.sql.gz (in the $HOME folder) would be:
where you would obviously need change the DB_USER and DB_PASSWORD values to what user and password you setup for the DB.
Remember:
FTP the DB and RESTORE it... Step by Step
-
If you aren't familiar with the command line and you really want to stick with a GUI style import then you can use BigDump (http://www.ozerov.de/bigdump/). I used it once but it's been a while. From what I remember you will download a file named bigdump.php (with some instructions) and put it on your webserver in the directory with the MySQL DB dump file that is too large to import via PHPMYADMIN. Then navigate to it using your browser - something like http://your-website.com/bigdump.php.
-
If you are familiar with the command line and using a Linux based system then you can use code like like this:
mysql -u USERNAME -p DATABASENAME
The database and user (with privileges to the database) will need to exist prior to running this command though. Note I copied the above command from another source. I always do my dumps and restores like this:
DUMP:
mysqldump -u DB_USER -h DB_HOST -pDB_PASSWORD DB_NAME | gzip -9 > DB_NAME.sql.gzRESTORE: `gunzip
FTP & RESTORE instructions:
Download FileZilla here: http://filezilla-project.org/download.php?type=client
Typically you can FTP into your server (especially a shared host) using the same login and password you would for SSH (you command line login). Just make sure to set up the connection to your server properly in FileZilla.
Once connected your default path will likely be your $HOME folder (on nix machines). If you aren't planning on doing a lot of FTPing just dump what you want in there. You can always move it from the command line.
If you FTP'd a MySQL Dump into your $HOME folder then the RESTORE command for a DB named mydb and a db dump file named mydb.sql.gz (in the $HOME folder) would be:
gunzip < $HOME/mydb.sql.gz | mysql -u DB_USER -pDB_PASSWORD mydbwhere you would obviously need change the DB_USER and DB_PASSWORD values to what user and password you setup for the DB.
Remember:
- The DB must already exist (but be empty) before the RESTORE command is executed
- The DB_USER and DB_PASSWORD must be setup for the DB before the RESTORE command (you can do this from PHPMYADMIN - Privileges tab)
- When you set up DB_USER from PHPMYADMIN it will default to only allowing DB_USER to access the DB from localhost (the server the DB is hosted on). I'm assuming this is fine for your situation grant. When you get into more advanced DUMPs and RESTOREs you may want to do it from another machine entirely which isn't hard but requires a couple more pieces of information be provided and DB_USER with the proper privileges.
FTP the DB and RESTORE it... Step by Step
- Locate zipped MySQL dump file on your desktop (Example: C:\Web\DB\Dumps\mydb.sql.zip)
- Download and install FileZilla
- In FileZilla go to File->Site Manager and click on the New Site button (lower left quadrant of GUI). Set the host to a domain (Example: dest.com) on that resides on your DESTINATION server. Set Protocol to FTP or SFTP (this depends on your hosting, ask them). Set the User and Password (Example: User = grant, Password = grant's password) - if the FTP protocol is SFTP then any set of valid SSH login credentials should work.
- (In FileZilla) Click Connect (bottom left most button)
- (In FileZilla) Once connected to the remote server (should be your DESTINATION server) use the left side of FileZilla to navigate to the directory where the dump file you located in Step 1 resides. (The path for the local machine is on the far left, about half way down and it is labeled Local site:. In our example the textbox next to Local site: would read C:\Web\DB\Dumps.)
- (In FileZilla) Locate the Remote site: label directly to the right of Local Site:.
- (In FileZilla) There is no technical reason you can't put the DB DUMP in the folder tha FileZilla opens up to. It will likely default to your $HOME directory. If you don't have any reason to put the DB Dump in a specific directory - such as for your own organizational purposes - then leave the path on the Remote site alone. Write down that path (Linux Example: /usr/grant).
- (In FileZilla) Locate the file on your local machine on the left half of FileZilla just under the Tree shown beneath the Local site: label you found in Step 5. Double click on that file and FileZilla will FTP it to your Remote Site.
- Within PHPMYADMIN on your DESTINATION server, create a new database (type mydb into the Create new database textbox and Click the Create button).
- (In PHPMYADMIN) Choose mydb from the menu on the left.
- (In PHPMYADMIN) Click on the Privileges tab (upper right). Once on that page click on Add New User.
- (In PHPMYADMIN->Privileges->Add New User) Provide a username (Example: mydb_grant) and password (Example: mydb_password). In the Host dropdown choose Local. Make sure that the radio button next to "Grant all privileges on database" is selected. Then click Go (bottom right of screen).
- SSH into your DESTINATION serve
Code Snippets
gunzip < $HOME/mydb.sql.gz | mysql -u DB_USER -pDB_PASSWORD mydbContext
StackExchange Database Administrators Q#7746, answer score: 12
Revisions (0)
No revisions yet.