"use db_name" fails with error #1046 on MySQL, message = "no database selected"

290 views Asked by At

I haven't used MySQL for a while, so forgive me if this is a silly issue with a simple solution. I have checked similar questions on the site, and in the majority of cases, the asker simply forgot to create or specify the database. This is not the case here.

I get the message

 Error: #1046 No database selected

After running the following instruction

 USE db_name;

For example:

 USE test;

I've tried several databases, but I get the same error with all of them. Creating databases works, that is, the database is created, but the same error message is still shown. If I try to SELECT * on a table from an existing database after specifying it:

USE db_name;
SELECT * FROM table_name;

I get the error:

#1146 - Table 'db_name.table_name' doesn't exist

I'm using MariaDB, version 10.4.14 with root user.

0

There are 0 answers