Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysqldbcompare fails with schemas with a '-' in their name

The following command fails

mysqldbcompare --server1=un:pw@server1 --server2=un:pw@server2 --difftype=sql store-staging:store-beta

with the following error:

mysqldbcompare: error: Cannot parse the specified database(s): 'store-staging:store-beta'. Please verify that the database(s) are specified in a valid format (i.e., db1[:db2]) and that backtick quotes are properly used when required. The use of backticks is required if non alphanumeric characters are used for database names. Parsing the specified database results in db1 = 'store' and db2 = 'store'.

My question is how can I 'escape' the schemas so that they can be run as part of this command?

I have tried all of the following:

'store-staging:store-beta'
"store-staging:store-beta"
`store-staging:store-beta`

'store-staging':'store-beta'
"store-staging":"store-beta"
`store-staging`:`store-beta`

and they all fail.

like image 554
Clarkie Avatar asked Feb 08 '23 01:02

Clarkie


1 Answers

It is probable that any backticks you intend for mysqldbcompare are actually being interpreted by the shell before mysqldbcompare actually sees them.

Try including the backticks inside quotes to ensure that they get properly passed, so your command looks something like this:

mysqldbcompare --server1=un:pw@server1 --server2=un:pw@server2 --difftype='`sql store-staging`:`store-beta`'

like image 181
Dezza Avatar answered Feb 16 '23 20:02

Dezza