What do you mean by default MySQL database for the user?


Actually, there is no default database for the user. But we have default database for the current session. It can be seen from the following query −

mysql> Select Database();
+------------+
| Database() |
+------------+
| sample     |
+------------+
1 row in set (0.00 sec)

The above result set shows that we are using ‘sample’ database currently. It is set for the current session. We can set another database, with the help of USE statement, also for the current session as follows −

mysql> USE query;
Database changed

mysql> Select Database();
+------------+
| Database() |
+------------+
| query      |
+------------+
1 row in set (0.00 sec)

Now, ‘query’ would be the default database for the current session.

Updated on: 28-Jan-2020

105 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements