简体   繁体   中英

mysql database from linux command line with dot in database name

I have mysql database which has dot in database name

database name = "abc.domain.com"

my query for linux command line is

mysql -u"root" -p"123" -h 0 -e"USE information_schema;select column_name, column_type from information_schema.columns where TABLE_SCHEMA = `abc.domain.com` AND table_name=`bugs`;" | column -t > /tmp/describe

in above command I am writing database name in between backticks `` it understand as linux command.

In mysql it is working fine.

how to solve this problem?

Try this:

/bin/sh -c mysql -u"root" -p"123" -h 0 -e"USE information_schema;select column_name, column_type from information_schema.columns where TABLE_SCHEMA = \\\`abc.domain.com\\\` AND table_name=\\\`bugs\\\`;" | column -t > /tmp/describe

Or

    $ export F='USE information_schema;select column_name, column_type from information_schema.columns where TABLE_SCHEMA = `abc.domain.com` AND table_name=`bugs`;'
    $ printenv F
    USE information_schema;select column_name, column_type from information_schema.columns where TABLE_SCHEMA = `abc.domain.com` AND table_name=`bugs`;
   /bin/sh -c mysql -u"root" -p"123" -h 0 -e $F | column -t > /tmp/describe

EDIT1:

Access denied for user 'root'@'localhost' (using password: NO)

It's not advisable to use root without password How to Reset the Root Password

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM