mysqldump syntax error - password being used as database name : <p>I'm trying to duplicate a MySQL (5.5.64-MariaDB) database on the same server by following this guide: <a href="https://stackoverflow.com/questions/675289/cloning-a-mysql-database-on-the-same-mysql-instance">Cloning a MySQL database on the same MySql instance</a></p>

<p>The accepted answer didn't work so I reviewed the docs over at MySQL and found that the <a href="https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html#mysqldump-option-summary" rel="nofollow noreferrer">mysqldump Options</a> used <code>--user</code> and <code>--password</code> instead of the <code>-u</code> and <code>-p</code> flags on the linked post.</p>

<p>When I execute this:</p>

<pre><code>mysqldump --user myUser --password myPassword dev_db | mysql -umyUser -pmyPassword staging_db
</code></pre>

<p>It firstly asks me to enter a password:</p>

<blockquote>
  <p>Enter password: </p>
</blockquote>

<p>So I enter <code>myPassword</code> although unsure why as it's given in the arguments list.</p>

<p>Then it gives the following error:</p>

<blockquote>
  <p>mysqldump: Got error: 1049: "Unknown database 'myPassword'" when selecting the database</p>
</blockquote>

<p>If I try entering the <code>--username</code> and <code>--password</code> <em>without spaces</em>:</p>

<pre><code>mysqldump --usermyUser --passwordmyPassword dev_db | mysql -umyUser -pmyPassword staging_db
</code></pre>

<p>It errors</p>

<blockquote>
  <p>mysqldump: unknown option '--usermyUser'</p>
</blockquote>

<p>The intention of this is to copy <code>dev_db</code> into a database called <code>staging_db</code>. 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.</p>

<p>Why doesn't this work?</p>

<p>If I use:</p>

<pre><code>$ mysql -umyUser -pmyPassword
</code></pre>

<p>It connects without any issue and gives me the MariaDB command prompt.</p>

<p>Server is running CentOS Linux release 7.7.1908 (Core) </p>

<p>Database version:</p>

<pre><code>$ mysql -V
mysql  Ver 15.1 Distrib 5.5.64-MariaDB, for Linux (x86_64) using readline 5.1
</code></pre>
