I want to make a duplicate of mysql database. So in my database a I went to export and exported the whole database. I received a file named a.sql. Then I went to my new database with the name b and went to import and tried to import my file a.sql But nothing happens. Am I doing something wrong?
I would use Sequel Pro.
Once you establish connection with your db:
File > Import > Browse to your SQL file...
Shouldn't have any issues using this
You are probably looking for MySQL Dump.
Run this on the command line:
Export:
mysqldump -u username -p[password] dbname > dbname.sql
Import:
mysql -u username -p[password] dbname < dbname.sql
If you only have access to PhpMyAdmin, then you can follow a guide. I found this one from a google search.
Related
I am exporting database from PHPMYADMIN. Database has 341 tables on remote server but when I import Sql file into local server PHPMYADMIN I got only 213 Tables.
Question :
How can I get all tables of database on localhost.
phpmyadmin should export all when you do export -> quick, but try to use the custom option and make sure all are selected. Also, may want to check the mysql mode (select ##global.sql_mode) of local and remote. If your local has default settings, there may be some tables with data in a column that's not allowed.
Assuming that your database is pretty large then you may have more success with exporting it via the command line rather than phpMyAdmin:
/usr/bin/mysqldump -u USERANME -p DATABASE_NAME > output.sql
Run that, you'll be prompted for your database password and then you'll get output.sql containing your database
You can then import this using ..
/usr/bin/mysql -u USERNAME -p DATABASE_NAME --no-create-db < output.sql
I'm trying to import a sql file that is on the server using the following command in the terminal
mysql -u NAME -p DBNAME < path/to/FILE.sql
when i do that it asks for the password, after inputting the password nothing happens. I check the database and no tables have been added.
Note:
DBNAME is created in the mysql database.
I have also tried the following syntax in mysql and also that didn't work
mysql> source PATH/TO/FILE.sql
Please Help :D
The sql file was corrupt, all i had to do was delete it and upload it once again. thanks #CBroe
Hello you can trying with
Create the database for import the tables:
mysql -u root -p
create database database_name;
exit
mysql -u user -p databasename < databasename.sql
I have a sql file containing data that I want to import to a table on MySQL.
I know the dead easy way is to use a a management software like MySQL work bench and import it that way but I want to learn how to it by command line
I already have sftp the file to the root directly on my linux system but im unsure how to import the data from the .sql file to the table I have in my database.
Use the file as input to the mysql command from the shell command prompt.
$ mysql -h servername -u username -p databasename < filename.sql
You will then be prompted for your password.
If you're already inside the mysql program, you can use its source command.
mysql> source filename.sql
I'm executing on a Centos Linux server this command:
mysql -u root -p mydatabase < dump.sql
I enter the password. It seems that all is ok because I absolutely get no errors, no messages that something happened. But sadly, the file is not imported!
Tryed in different ways:
-Putting the sql file in another location.
-Creating the DB first and than without the DB.
-Avoiding the dbname
-Adding max_allowed_packet=800M in /etc/my.cnf (because the file is 490mb)
-Restarted Mysql. But nothing to do. No errors, no import. I'm stuck and in panic. What to do? ?
If you have already created database then use below steps to import data from .sql file
DataBase to use:
use DataBaseName;
Give the source file path
source /path/to/dump.sql;
Hope this will help
I'm trying to import an sql dump into mysql. I selected in command prompt the directory where the file is and I'm using the following command( from inside the file's directory):
mysql -u root -p password database < file.sql
It doesn't show any specific detail regarding this, it just shows the list of all the options I have, like in a help. I'm not an advanced user of mysql, maybe you have an idea why it isn't working. Thanks.
Place the password immediately after -p. Also, you misspelled mysql:
mysql -u root -ppassword database < file.sql