Page 1 of 1
how to import a database
Posted: Tue Oct 07, 2008 4:09 pm
by amin3d
Hello every one.
These days i have faced to big problem . it is g database my database. My database type is mysql and it is so big. i want to know how can i import a database except using Phpmyadmin and things that i must say about my condition are my database is on myftp and the extension of it is .gz and my server is Linux and dont access to shell to use its command for importing database.
Thanks
Re: how to import a database
Posted: Tue Oct 07, 2008 4:14 pm
by onion2k
You need shell access, or you need to get someone who has shell access to do it for you. Running a large scale SQL dump through a browser is a bit impractical.
Or, alternatively, you could break the SQL file up into smaller chunks.. they are just text files really so you split them into smaller bits and run them one by one. Though that really depends how big it is.. if your database is gigabytes in size that's still a bit impractical.
Re: how to import a database
Posted: Tue Oct 07, 2008 4:25 pm
by amin3d
Thanks for reply .Could you tell me how to split my database in small part and say me after splitting how to import with phpmyadmin?
Thanks
Re: how to import a database
Posted: Tue Oct 07, 2008 4:49 pm
by onion2k
No.
I could easily, but there was less than 10 minutes between my post and your reply, so you clearly haven't bothered to think about it at all. If you aren't going to put any effort into finding a solution to your problem then I see no reason why I should.
Re: how to import a database
Posted: Tue Oct 07, 2008 4:59 pm
by VladSun
A little hack to gain sheell-like access
Create a php file in your web root directory:
Code: Select all
<?php
echo system("gunzip /full/path/to/database_backup.gz -c | `which mysql` -u YOUR_DB_USERNAME -pYOUR_DB_PASSWORD DATABSE_NAME 2>&1");
?>
and by using your www browser browse it ONCE.
If there are any errors they will be displayed in your browser - fix'em and retry.
After finishing the import - remove this file.
PS: Please, notice there is NO white space between -p and YOUR_DB_PASSWORD - this is how it SHOULD be.
Re: how to import a database
Posted: Sat Oct 11, 2008 1:01 pm
by amin3d
it was a great help. now let me know how to import it with specific charachter encoding such as utf-8 or the same as that.
Regardes
Re: how to import a database
Posted: Sat Oct 11, 2008 3:01 pm
by VladSun
Re: how to import a database
Posted: Sun Oct 12, 2008 5:52 am
by amin3d
thanks for above link. here is a problem i dont know how to add or set Default Character Set and Collation in that command .For example add utf-8 and utf8_unicode_ci collation.
Please help me.
Re: how to import a database
Posted: Sun Oct 12, 2008 7:00 am
by VladSun
Read the man-page
o --default-character-set=charset_name
Use charset_name as the default character set. See Section 8.1, "The
Character Set Used for Data and Sorting".
Re: how to import a database
Posted: Mon Oct 13, 2008 12:14 pm
by amin3d
I've read it. But my problem is how to use them . because i've got some errors like below.
/usr/bin/mysql: unknown option '-d' /usr/bin/mysql: unknown option '-d'
Re: how to import a database
Posted: Mon Oct 13, 2008 2:35 pm
by VladSun
I know -D, not -d ...