Help - Search - Members - Calendar
Full Version: How Do I upload my SQL file?
The Planet Forums > System Administration > Backups, Restores and Transfers
NemoTech
I am able to access phpMyAdmin but there is a 2MB limit on the file I can import into my database. My SQL file is around 30 MB. How can I import this file to my database? I believe I will need to telnet in, please any help.

Thank You.
skeeter1jd
SSH in, and then import via mysql or send to the server admin and have them do the import.
mmyers
NemoTech,

The 2MB limit is most likely a setting in the php.ini file. By default, PHP has an upload limit of 2MB. Since phpMyAdmin is written in PHP, it inherits this limitation. If you can modify the php.ini file to remove this limit, then you should be able to import it via phpMyAdmin. However, that limitation is global for anything with php, so it might cause problems for any other php applications you have running.

Probably a better way to import your sql file would be to upload it to the server and import it directly using the mysql client, as skeeter1jd described. The mysql client is actually a network client which connects to a mysql server, localhost by default. So, if you have a mysql client on your workstation and your mysql server is listening for incoming connections (typically not done because it is insecure), then you can just do like,

'mysql -h server < sqlfile.sql'

and it'll upload it to your mysql server directly using the client. This won't be the most secure way to do it, but it will at least eliminate any dependencies on other applications.
NemoTech
Thanks exactly what I was looking for... I'll be tinkering with it tonight. Hopefully I get it going. Thanks once again. icon_smile.gif
NemoTech
Two questions?

How would I upload to the server?

I can log into my website ftp and upload there. But then it will be in location /var/www/html/ ...

Also how do I execute the mysql command. By telneting in?
mmyers
If you upload via FTP, depending on your FTP server configuration you should be able to place the file anywhere you want. If not, after uploading you can SSH (assuming you are using a linux server) and move the file wherever you need it.

If you're uploading a .sql file, it should essentially be an sql script. All that would need to be done would be to provide that script as input for the mysql client, such as with the following command:

mysql < sqlscript.sql

or if you need to specify a database;

mysql somedatabase < sqlscript.sql
NemoTech
QUOTE (mmyers @ Oct 12 2007, 02:34 AM) *
If you upload via FTP, depending on your FTP server configuration you should be able to place the file anywhere you want. If not, after uploading you can SSH (assuming you are using a linux server) and move the file wherever you need it.

If you're uploading a .sql file, it should essentially be an sql script. All that would need to be done would be to provide that script as input for the mysql client, such as with the following command:

mysql < sqlscript.sql

or if you need to specify a database;

mysql somedatabase < sqlscript.sql


I've never logged in using ssh. I'll upload the file now and go thru the steps you outlined. I may return to this thread if I encounter problems. Thank you very much. just beginning with my sites on this server so many dumb/n00b questions on my end. Thanks again. Later.
NemoTech
I do not have a telnet client on my pc computer. What program should I get, or recommend, to SSH into my site?

Thank you.
NemoTech
okay I logged into ssh using the same user and pass for the ftp of a site I am hosting. Here is my problem...


-bash-3.00$ mysql < my13.sql
ERROR 1045 (28000): Access denied for user 'pacshakurnet'@'localhost' (using password: NO)

should I use my database user and pass?
skeeter1jd
mysql -u pacshakurnet -p <databasename> < my13.sql
NemoTech
Thank you sir, that should do it. Just working my thru icon_biggrin.gif
NemoTech
does -u mean username or just u.. same with -p, does that mean enter password?
skeeter1jd
yes....

http://linux.die.net/man/1/mysql
NemoTech
I did exactly as you said, I get an error saying.. no such file or directory.
NemoTech
Let me mess with this more. I'll holler when I am out of luck. THanks for the time being icon_biggrin.gif.
NemoTech
I think i got. thanks so much guys, you were great icon_biggrin.gif.
NemoTech
Question now for the opposite...

How would I dump the database to a file.. by doing the following???
mysql -u pacshakurnet -p <databasename> > filename.sql
skeeter1jd
That would depend on the options you want. Something like this would work for most export/import operations providing you put in all the variables.

CODE
mysqldump --user=$USER --password=$PASSWORD --opt --add-drop-table --add-locks --quote-names --extended-insert --compatible=mysql323 $I > $DB_DUMP_LOCATION/$I.sql && gzip -f $DB_DUMP_LOCATION/$I.sql
skeeter1jd
Thats all one line too by the way.
NemoTech
QUOTE (skeeter1jd @ Oct 25 2007, 05:26 PM) *
That would depend on the options you want. Something like this would work for most export/import operations providing you put in all the variables.

CODE
mysqldump --user=$USER --password=$PASSWORD --opt --add-drop-table --add-locks --quote-names --extended-insert --compatible=mysql323 $I > $DB_DUMP_LOCATION/$I.sql && gzip -f $DB_DUMP_LOCATION/$I.sql


What would $I be?
mmyers
From the syntax, $I should be the name of the database.
NemoTech
QUOTE (mmyers @ Nov 2 2007, 11:37 PM) *
From the syntax, $I should be the name of the table.


I'm not interested in dumping just a table. I'd like to dump the entire database. I tired the following and received error 1044:

"mysqldump: Got error: 1044: Access denied for user 'pacshakurnet'@'localhost' to database '2pacshakur_net_-_vb368' when using LOCK TABLES
"

I used the command below.
mysqldump -u pacshakurnet -p 2pacshakur_net_-_vb368 > dump.sql
mmyers
QUOTE (NemoTech @ Nov 3 2007, 06:49 AM) *
I'm not interested in dumping just a table. I'd like to dump the entire database. I tired the following and received error 1044:

"mysqldump: Got error: 1044: Access denied for user 'pacshakurnet'@'localhost' to database '2pacshakur_net_-_vb368' when using LOCK TABLES
"

I used the command below.
mysqldump -u pacshakurnet -p 2pacshakur_net_-_vb368 > dump.sql


You will also need to specify the table, so you should use something like the following:

CODE
mysqldump -u pacshakurnet -p 2pacshakur_net_-_vb368 mysqltable > dump.sql


If you want to back up a whole database, use the --databases option, like so:

CODE
mysqldump -u pacshakurnet -p 2pacshakur_net_-_vb368 --databases mysqldatabase > dump.sql


Or you can replace --databases with --all-databases and get everything dumped.
skeeter1jd
The name of the database in question...
mmyers
QUOTE (skeeter1jd @ Nov 8 2007, 12:12 AM) *
The name of the database in question...


err, yeah, thats what I meant, heh.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.