Error 1049: Unknown database '–-single-transaction' - mysql

I can't seem to get mysqldump to accept the --single-transaction flag when I pass it as an option.
If I run this:
mysqldump -u root –-single-transaction --databases test > /dev/null
Or this:
mysqldump -u root –-single-transaction test > /dev/null
Then I get the message:
mysqldump: Got error: 1049: Unknown database '–-single-transaction' when selecting the database
I'm using version 5.6:
mysqldump --version
mysqldump Ver 10.13 Distrib 5.6.24, for Linux (x86_64)
What's going wrong here?

Look VERY closely:
mysqldump -u root –-single-transaction test
^--this is not a dash
It's some wonky unicode char (ndash, maybe?), which means it's treated as a DB name, NOT a command line option.

Related

Mysql restore issue

I used to have mysql 5.6 server. I backed up with like this command.
mysqldump -u Myuser -pMypasswor Mydatabase > C:\backups\Mydatabase.sql
I removed Mysql 5.6 and installed 5.5 version.
Now I try to restore my database but it fails. Firstly I tried this
mysqldump -u Myuser -pMypasswor Mydatabase < C:\backups\Mydatabase.sql
Afterwards on Cmd Connected with
mysql -u Myuser -pMypassword
Mydatabase < C:\backups\Mydatabase.sql
I got this error
ERROR:
Unknown command '\a'.
ERROR:
Unknown command '\m'.
ERROR:
Unknown command '\I'.
-> ;
I googled but I cant solve my own
Any idea is appreciated

Error after moving MySQL DB to another computer (both Ubuntu, 14.04 and 16.04)

I'm trying to move a MySQL DB from version 14.14 Distrib 5.5.50 to another machine with 14.14 Distrib 5.7.13 (both machines are Ubuntu, 14.04 and 16.04 respectively)-
I've always managed to do it with these commands:
1) Backing up on origin-computer:
Users:
$ MYSQL_CONN="-uroot -ppassword"
$ mysql ${MYSQL_CONN} --skip-column-names -A -e"SELECT CONCAT('SHOW GRANTS FOR ''',user,'''#''',host,''';') FROM mysql.user WHERE user<>''" | mysql ${MYSQL_CONN} --skip-column-names -A | sed 's/$/;/g' > ${TEMP_DIR}"/"${MYSQL_DIR_NAME}"/users.sql"
Databases:
$ mysqldump -uroot -ppassword --all-databases > ${TEMP_DIR}"/"${MYSQL_DIR_NAME}"/databases_TMP.sql"
2) Restoring on destiny-computer:
Users:
$ mysql -uroot -ppassword < users.sql
Databases:
$ mysql -uroot -ppassword < databases_TMP.sql
And it has always worked for me until now.
This time, no matter the order in which I take these steps or any combination/modification on the parameters, it is not working and I can't figure out why it's not working.
Every time I finish the process, when I launch the MySQL Workbench and click any user, inmmediately I get this error message:
"Unhandled exception: object of type 'NoneType' has no len()"
I have no clue what can I do to solve it, so any idea will be really welcomed.
Just in case someone else had the same problem:
Using the mysqldump command instead of the one I posted in my question worked fine:
$ mysqldump -uroot -ppass --all-databases > databases.sql
However, because of MySQL versions on both computers I also had to go through this other problem:
MySQL unknown column 'password_last_changed'
And finally now I have everything working again.

dumping DB in mysql

when I run below statement, mysql is complaining having error.
mysqldump --triggers --routines -u root -p mydb > mydb_20120924.dmp;
mysql version: 5.1.34
You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near 'mysqldump --triggers --routines -u root -p mydb > mydb_20120924.dmp' at line 1
It looks like you are trying to run the mysqldump command from inside the mysql command line interpreter.
Does the prompt for the mysqldump command say 'mysql> '? Then you are running the mysql command line interpreter. It should be used - indeed, it can only be used - for running mysql commands.
mysqldump is a separate command and must be run from the shell.
Quit mysql by typing "exit" - you will see a shell prompt. Then the mysqldump command will work.
If you have a database called "mydb" this should work. You could try using --database specifically:
mysqldump --triggers --routines -u root -p --database mydb >
mydb_20120924.dmp;

mysql dump, windows, seperate files for each DB, all databases option

Does anybody have an example on how to dump all databases uses mysql dump? And possible all a new file for each DB?
I'm using the follow command:
mysqldump -u root -p pw --all-databases > backup.sql;
It's returning with "You have an error in your SQL sytax";
Thanks!
There is an error in your command, it should be no space after -p,
like
mysqldump -u root -ppw --all-databases > backup.sql;
I not sure how many database you have, usually you can do this :-
mysqldump -u root -ppw db_a > db_a.sql;
mysqldump -u root -ppw db_b > db_b.sql;
...
... for all the databases

mysql dump error

I'm having some difficulty with mysqldump. I locked my tables and ran the following command:
mysqldump -u user -p password databasename using my actual password and database name.
When I run this from mysql I get a 1064 error that says there is an issue with my syntax. I've also tried running the command from terminal (outside of mysql) and receive a 'command not found' error message. I'm not entirely sure how I should be doing this (the explanations I've found so far have been vague).
Thanks for the help.
The mysqldump is a program, it cannot be executed from the mysql console. Run it from the shell.
Have a look at the syntax reference.
--user=user_name, -u user_name
--password[=password], -p[password]
As you see there is no space between -p and password. So, your command line should be like this:
>shell mysqldump -u <user_name> -p<user_password> ...
or
>shell mysqldump --user=<user_name> --password=<user_password> ...
You are missing the target backup file name:
# [mysql dir]/bin/mysqldump -u username -p password --databases databasename > /tmp/databasename.sql
MySQL Commands
the correct syntax is
mysqldump -u [username] -p[password] [databasename] > [backupfile.sql]
you should add the > backupfile.sql
the other error is believe your system doesn't recognize the mysqldump path and you should go directly to bin folder from mysql installation.