mysql 命令 show databases 出错“ERROR 1064 (42000): You have an error in your SQL syntax”

ERROR 1064 (42000): 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 'show databases' at line 2

错误信息提示了两点可能导致报错的关键:

    1.版本不同

    2.语法错误

1.版本不同解决方法:

首先,登录

C:\Users\Ztruehow>mysql -uroot -p(加上你设置的密码)

 系统会自动显示出当前的版本号:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 27
Server version: 8.0.19 MySQL Community Server - GPL

我的版本是8,所以查看系统自带数据库的代码为:

mysql> SHOW DATABASES;

我看的教程上,老师的版本是5,此时代码为:

mysql> show databases;

(注意拼写)

2.语法错误解决办法:

mysql> show datebases
ERROR 1064 (42000): 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 'databases;

很简单,记得加分号

mysql> show datebases;

最后总结:不同版本需要区分大小写,检查拼写正确,别忘分号。

(1)

自我纠错:sql语句不区分大小写,之前鄙人小写报错,是因为把databases打成了datebases。

纠错后的总结:检查拼写是否正确,别忘记分号;(这里不能输中文的;而要输英文的;)

猜你喜欢

转载自blog.csdn.net/threeeyedraven/article/details/107772409