use*_*056 2 mysql database shell command
我想使用以下语法创建数据库
mysql -u<uname> -p<password> -e "create database <name>"
Run Code Online (Sandbox Code Playgroud)
但是每当我尝试在数据库名称中使用点(。)时,都会出现错误。
[root@aee9a1889c3f wpg.master]# mysql -uroot -proot -e "create database 'a.n'"
Warning: Using a password on the command line interface can be insecure.
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''a.n'' at line 1
[root@aee9a1889c3f wpg.master]#
[root@aee9a1889c3f wpg.master]#
[root@aee9a1889c3f wpg.master]# mysql -uroot -proot -e "create database `a.n`"
bash: a.n: command not found
Warning: Using a password on the command line interface can be insecure.
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Run Code Online (Sandbox Code Playgroud)
我知道我可以使用像SQL pro这样的sql编辑器或使用mysql命令编辑器来做到这一点,但是我想这样做。请帮忙。
提前致谢
如果使用该mysqladmin实用程序,则可以完成以下操作:
mysqladmin -u<uname> -p<password> create a.n
Run Code Online (Sandbox Code Playgroud)
如果要使用mysql客户端执行此操作,则需要使用单引号(以避免反引号(`)的shell扩展。
mysql -u<uname> -p<password> 'create database `a.n`'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
315 次 |
| 最近记录: |