import .sql file into database found on a server - php

i am using phpmyadmin and i exported the database which I had locally. The exported file has an extension of .sql. I want to import the exported database into a database found online on the server. The server doesnt use phpmyadmin. I already connected to the database using SQL wave software however it doesn't offer the import feature like phpmyadmin does. After i installed mysqldumpler however i have the same problem. I cannot browse and import a .sql file. Can someone tell me how i can import the .sql file into my live database? Maybe a software you know or a command?

Copy the file to server. SSH into the server. Then you can load with the command line client:
mysql -u username -p dbname < path/to/file.sql
You will need to create the DB first.

Related

Entering large file of sql to phpmyadmin database

What is the SQL code to import an database to phpMyAdmin? I have tried using the import tab but it does not allow to import as the file size is too large than the given limit???
You need to use MySql CLI:
> mysql -uUser -pPassword
> use DatabaseName
> source full_path_till_file.sql
Use BigDump from http://www.ozerov.de/bigdump/. Just put this script and your big SQL file on FTP and run the script. I tried it on ~2GB SQL file and it works without any problems.

how to dump mysql db from terminal macbook

I'm a new MacBook Pro user.
Because the file is so large, I need to import it from terminal.
I already know how to import and export MySQL data using terminal in Linux,
but since I'm newbie in the iOS environment, I'm lost.
I think I'm missing something, maybe the path or anything, I just don't know.
I'm using XAMPP. I access my htdocs file from terminal, with this
cd /Applications/xampp/xamppfiles/htdocs/abcFolder
and then i try to import my db with this :
mysql -u root mir_existing < mirdb_21_november_2016\ \(1\).sql
Since I have no password, I remove the -p syntax.
But when I press enter to run the script, the result is command not found.
Many of you referred me to this page.
How can I access the mysql command line tool when using XAMPP in OS X?
I already did it, but I don't know where to access my mysql file path to import the db. It's different.
For example. i need to run this script to import the db right?
mysql -u mysql_user -p DATABASE < backup.sql
for example, my backup.sql is on htdocs/abcFolder/backup.sql
How can access it ?
Should I try this?
mysql -u mysql_user -p DATABASE < htdocs/abcFolder/backup.sql
i already tried that thing.
nothing happen. sigh.
How do I import my db?
If doing
which mysql
doesn't yield any results, you'll need to add the /path/to/mysql to your PATH variable and put it in your .bash_profile or .bashrc for future use so you don't have to keep adding it. After adding it to one of these files, just do
source .bash_profile
or
source .bashrc
depending on where you put it.
e.g. on one of my macs I use MAMP and need access to the bins it provides (mysql among them) so this is in my .bash_profile:
export PATH="$PATH:/Applications/MAMP/Library/bin"

Why the database dump is not getting imported in following scenario?

I've one 'xyz.sql' dump file uploaded in 'test' folder on the server.
Created a blank database called 'dummy' in MySQL database using PHPMyAdmin.
Then I logged into the server using ssh and run the following command, it gave me no error but the database is not getting imported.
mysqldump -uroot -pxyz123 new_db > xyz.sql
The username I use to login to the PHPMyAdmin is root and password is xyz123. The blank database I created is 'new_db', the file which I want to import is xyz.sql.
You can see in above command I've used these details.
Try using < instead of > when you import the dump. First check if xyz.sql still contains your dump!

cannot import too large sql file to mysql

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.

How can I convert MySQL database to SQLite in PHP?

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...

Categories