Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
Hi I want to insert sql database dump file in remote mysql server machine. i am using currently putty tool for doing this task. i have used lot of command but i am not able to do this. and i have also created database on that server but now i want insert database sql dump from server directory into mysql server.
I have also uploaded sql dump into home directory RHEL OS remote server machine.
i have used some command like -
mysql> use database_name;
mysql> mysql -u username -p database_name < /home/dump.sql;
mysql> mysql -u username -h host_ip -p database < /home/dump.sql;
mysql> mysql -u username -h host_ip -p database < /home/dump.sql;
mysql> mysql -u username -h host_ip -p dbpass -d database < /home/dump.sql;
mysql> mysql -u username -h host_ip database < /home/dump.sql;
mysql> plink mysql -u username -h host_ip -p database < /home/dump.sql;
and other command but i could not import sql dump into db server.
Please help me.
Thanks.
i think you are missing the password after -p syntax is
mysql -u username -p password db_name < /home/dump.sql
other possibility is that you are not providing proper directory or complete path of dump file
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I'm trying to duplicate a MySQL (5.5.64-MariaDB) database on the same server by following this guide: Cloning a MySQL database on the same MySql instance
The accepted answer didn't work so I reviewed the docs over at MySQL and found that the mysqldump Options used --user and --password instead of the -u and -p flags on the linked post.
When I execute this:
mysqldump --user myUser --password myPassword dev_db | mysql -umyUser -pmyPassword staging_db
It firstly asks me to enter a password:
Enter password:
So I enter myPassword although unsure why as it's given in the arguments list.
Then it gives the following error:
mysqldump: Got error: 1049: "Unknown database 'myPassword'" when selecting the database
If I try entering the --username and --password without spaces:
mysqldump --usermyUser --passwordmyPassword dev_db | mysql -umyUser -pmyPassword staging_db
It errors
mysqldump: unknown option '--usermyUser'
The intention of this is to copy dev_db into a database called staging_db. Both of these databases exist on the same server. The username/password I'm using has full access to every database on the MySQL instance.
Why doesn't this work?
If I use:
$ mysql -umyUser -pmyPassword
It connects without any issue and gives me the MariaDB command prompt.
Server is running CentOS Linux release 7.7.1908 (Core)
Database version:
$ mysql -V
mysql Ver 15.1 Distrib 5.5.64-MariaDB, for Linux (x86_64) using readline 5.1
You can't have a space before the password.
--password=myPassword
or
-pmyPassword
When the --password option doesn't have a directly connected parameter, it means to prompt for the password.
I am trying to connect mysql db using ansible but unable to login, how can I able to connect my mysql database using ansible and do operation like database dump- data restoration and .sql file execution.
you can just run it as a shell command in ansible:
mysql -u USER -p PASSWORD -h MYSQLSERVERNAME -e 'select * from foo...' database-name
mysql -u USER -p PASSWORD -h MYSQLSERVERNAME database-name < database_name.sql
see here, similar question with playbook snippet
This question already has answers here:
how can I export mysql database using ssh?
(3 answers)
Closed 9 years ago.
I want to download mysql database from server using command prompt in windows.
I tried to use ssh to connect to the server.
But, it is not working. Is there any command to this?
Exporting MySQL Data
This example shows you how to export a database. It is a good idea to export your data often as a backup.
Using SSH, execute the following command:
mysqldump -p -u username database_name > dbname.sql
You will be prompted for a password, type in the password for the username and press Enter. Replace username, password and database_name with your MySQL username, password and database name.
The file dbname.sql now holds a backup of your database and is ready for download to your computer.
To export a single table from your database you would use the following command:
mysqldump -p --user=username database_name tableName > tableName.sql
Again you would need to replace the username, database and tableName with the correct information.
Once done the table specified would then be saved to your account as tableName.sql
Have a look Backup or Schema/Data Comparison tools in dbForge Studio for MySQL. Command line and conencting through secure SSH connections are supported.
I have a backup of my database in mysql of 250MB !!
How can I restore it in a new database on another server ?
Or just use phpMyAdmin for restore porpoise.
You are providing no detail on what operating system you're on and what kind of backup you have, but the short answer is
mysql -u username -p -h hostname databasename < dumpfile.sql
where dumpfile.sql needs to be a file containing SQL statements, for example produced with mysqldump.
Using:
mysql -u USER -p -h HOST DATABASE < mysqldump.sql
I want to copy a mysql database from my local computer to a remote server.
I am trying to use the mysql dump command. All the examples on the internet suggest doing something like
The initial mysql> is just the prompt I get after logging in.
mysql> mysqldump -u user -p pass myDBName | NewDBName.out;
But when I do this I get You have an error in your SQL syntax; check the manual that corresponds ... to use near 'mysqldump -u user -p pass myDBName | NewDBName.out'
Since I have already logged in do I need to use -u and -p? Not doing so gives me the same error. Can you see what is wrong?
In addition to what Alexandre said, you probably don't want to pipe (|) output to NewDBName.out, but rather redirect it there (>).
So from the Windows/Unix command line:
mysqldump -u user -p pass myDBName > NewDBName.out
Note that if you have large binary fields (e.g. BLOBS) in some columns you may need to set an additional option (I think it was --hex-blob, but there might have been another option too). If that applies to you, add a comment and I'll research the setting.
mysqldump is not an SQL statement that you execute inside a mysql session but a distinct binary that should be started from your OS shell.
The are a few ways to use this. One of them is to pipe the output of mysqldump to another MySQL instance:
echo CREATE DATABASE remote_db | mysql -h remote_host -u remote_user -premote_password
mysqldump -h source_host -u root -ppassword source_db | mysql -h remote_host -u remote_user -premote_password -D remote_db
I have had to dump large sets of data recently. From what I have found on a 200Mb database with 10,000+ records in many of the tables is the following. I used the linux 'time' command to get actual time.
12 minutes using:
mysqldump -u user -p pass myDBName > db-backups.sql
7 minutes to clone the database:
mysqldump -u user -p pass myDBName | mysql -u user -p pass cloneDBName
And in less than a second:
mysqlhotcopy -u user -p pass myDBName cloneDBName
The last one blew my mind, but you have to be logged in locally where the database server resides. Personally I think this is much faster than remotely doing a dump, the you can compress the .sql file and transfer it manually.