-3

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
Andy
  • 5,142
  • 11
  • 58
  • 131
  • If you read the Accepted answer there is a subtile difference between your attempt at `mysqldump` and the answer HINT `--password=` !== `--passwordmyPassword` – RiggsFolly Feb 04 '20 at 11:22

1 Answers1

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.

Barmar
  • 741,623
  • 53
  • 500
  • 612