Error importing MySQL database using phpMyAdmin - php

I am importing a MySQL database from another server to my own server using phpMyAdmin. But the problem is:
I go into import then choose a file which have extension like .sql, .xml. After this procedure I click on the ok button but this doesn't give any response and doesn't even do anything, the page just remains stable.
I also tried with MySQL command prompt using mysqldump.
mysqldump -u username -p databse > database name
but this is also giving an error.
Can any one please help me in solving this?

This command is used to export :
mysqldump -h hostname -u username -p database > sql_file_name
to import you should use
mysql -h hostname -u username -p database < full_file_path

first you need to export a DB from the first server.
on your server you first need to create a new DB and than do the import.
the DB you imported will go to the DB you just created.

Related

Not able to import any sql file using command line in windows xampp

I am trying to import some .sql file (which contains my database) into xampp mysql database but no luck.
Here is my attempts :
step-1: I Entered into c:\xampp\mysql\bin>
step-2: And then used this command for import my sql file to my local database (I placed 'raj-db.sql' in 'c:\xampp\mysql\bin>' folder).
Step-3: After click on enter it is asking 'Enter password:' and immediately going to 'c:\xampp\mysql\bin>' path with out enter any password.
Please can you help me on this.I installed fresh xampp also but still behaving the same.
It is coming like this
c:\xampp\mysql\bin>mysql -u root -p my-db-name < file-name.sql
Enter password:
c:\xampp\mysql\bin>
If I run 'c:\xampp\mysql\bin>mysql' it is coming as 'MariaDB [none]>'.But usually it should come like 'mysql>'.
How to Load MySQL Database Dump Using XAMPP
Step 1 : Start your Xampp
Step 2 : Start your MySQL Server (if not already started)
Step 3 : Launch into CLI mode by clicking on the CMD button (black
button).
Step 4 : Copy your Database backup into same directory.
Step 5 : Load the backup into your already created Database using the
following command
mysql -u root -p DatabaseName < DatabaseDump.sql
You may use the attached screenshots as your guide.
Hope this helps.
Does the target database is already created? Import needs it created and empty for it to work.
CREATE DATABASE db-name
If it is already created try this and then import with your command:
use db_name;

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!

Uploading database mysql

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

Importing huge Database into local server

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.

Categories