Get the App
SLTechnology News&Howtos  ›  Database  › 

The error of the old version of mysql: how to solve ERROR 1046 (3D000): No database selected (BUG)

Shulou Source: shulou.com Published: 2022-05-31 17:53:55 11月14日 Update

The main content of this article is to explain "the error of the old version of mysql: ERROR 1046 (3D000): No database selected (BUG) how to solve", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "the error report of the old version of mysql: ERROR 1046 (3D000): No database selected (BUG) how to solve it"!

When the developer is given a sql, you need to do batch update for each library of the project. After writing it in the script, you will find a failure and report an error during execution.

ERROR 1046 (3D000): No database selected, the specified library name was found and a question was raised.

After confirming that the library name has been specified, then rewrite it into select and do a query, and find that the error is still reported.

If we take a closer look at sql, we can find that the writing of unhex function is not rigorous, that is, the parentheses are not followed closely.

That is, you need to replace unhex () with unhex ().

I went on to do a test and found that the error message was the same, but irrelevant:

Since the function is written irregularly, how does it have to do with whether or not to choose the database?

Mysql > SELECT NOW ()

ERROR 1046 (3D000): No database selected

Confirm the DB version:

Mysql > SELECT version ()

+-- +

| | 5.0.51a-24+lenny2-log |

+-- +

1 row in set (0.00 sec)

The ancient version, which is estimated to have more bug, has been tested with a new version of mysql5.5:

It is found that the error is normal:

Mysql > SELECT NOW ()

ERROR 1305 (42000): FUNCTION now does not exist

Probably guessed to be a BUG from the old version (mysql5.0). 5.1 No test was done.

However, no matter whether it is the old version or the new version, the error will be reported if the function name is not followed by parentheses, but the error thrown by 5.0 is so strange that people can't understand it.

Of course, adding "IGNORE_SPACE" to sql_mode can ignore such issues, but it is not recommended:

Mysql > SELECT VERSION ()

+-- +

| | VERSION () |

+-- +

| | 5.0.51a-24+lenny2-log |

+-- +

1 row in set (0.00 sec)

Mysql > SELECT NOW ()

ERROR 1046 (3D000): No database selected

Mysql > SHOW VARIABLES LIKE 'sql_mode'

+-+ +

| | Variable_name | Value |

+-+ +

| | sql_mode |

+-+ +

1 row in set (0.00 sec)

Mysql > SET @ @ session.sql_mode='IGNORE_SPACE'

Query OK, 0 rows affected (0.00 sec)

Mysql > SELECT NOW ()

+-+

| | NOW () |

+-+

| | 2016-03-18 02:00:14 |

+-+

1 row in set (0.00 sec)

At this point, I believe you have a deeper understanding of "the error of the old version of mysql: ERROR 1046 (3D000): No database selected (BUG) how to solve it", you might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Version function test content writing parenthesis learning query irregular rigorous practical deeper the same that is information interest but strange practical Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple macOS MariaDB Xiaomi MySQL