MySQL Workbench执行sql语句报错Error Code: 1046. No database selected Select the default DB......

出现缘由:

  1. 在workbench中操作删除了某选中数据库,
  2. 点击左上角第一个那个“+SQL”(create a new sql tab for executing queries )
  3. 打开.sql文件或者粘贴sql语句并执行
  4. 报错:Error Code: 1046. No database selected Select the default DB to be used by double-clicking its name in the SCHEMAS list in the sidebar.
    在这里插入图片描述

原因解释:
直译:错误代码:1046。未选择数据库通过在侧边栏的SCHEMAS列表中双击其名称,选择要使用的默认DB。
其实就是因为之前删除了选中的数据库,但是新Query进来前未选择一个默认数据库来操作数据

解决操作:

  1. 列表中双击需要操作的数据库
  2. 执行sql语句
  3. 成功,刷新一下就能看到选择的数据库中执行结果了
    在这里插入图片描述
    在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/Mr_Bobcp/article/details/107249702
今日推荐