gpt4 book ai didi

用点创建mysql数据库

转载 作者:搜寻专家 更新时间:2023-10-30 20:03:58 25 4
gpt4 key购买 nike

我想使用以下语法创建一个数据库

mysql -u<uname> -p<password> -e "create database <name>"

但是每当我尝试在数据库名称中使用点 (.) 时,它都会给我错误。

[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

我知道我可以使用像 SQL pro 这样的 sql 编辑器或使用 mysql 命令编辑器来做到这一点,但我想这样做。请帮忙。

提前致谢

最佳答案

如果你使用 mysqladmin 实用程序,它可以完成:

mysqladmin -u<uname> -p<password> create a.n

如果你想使用 mysql 客户端来完成它,你需要使用单引号(以避免反引号 (`) 的 shell 扩展

mysql -u<uname> -p<password> 'create database `a.n`'

关于用点创建mysql数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42768315/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com