简体   繁体   English

linux命令行中的mysql数据库,数据库名称中带有点

[英]mysql database from linux command line with dot in database name

I have mysql database which has dot in database name 我有mysql数据库,数据库名称中有点

database name = "abc.domain.com" 数据库名称=“ abc.domain.com”

my query for linux command line is 我对linux命令行的查询是

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. 在上面的命令中,我正在反引号之间写入数据库名称``它理解为linux命令。

In mysql it is working fine. 在MySQL中,它工作正常。

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: 编辑1:

Access denied for user 'root'@'localhost' (using password: NO) 用户'root'@'localhost'的访问被拒绝(使用密码:NO)

It's not advisable to use root without password How to Reset the Root Password 不建议使用没有密码的root用户如何重设root密码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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