The DATABASE() Function in MySQL returns the name of the default or current database. The string or name returned by DATABASE() function uses the utf8 character set. If there is no default database,the Database function returns NULL.
In the older versions than MySQL 4.1.1,The Database function used to return an empty string, if there is no default database.
The DATABASE() function is easy to use and does not accept any parameters. We can easily get the name of default database using the above syntax on MySQL console.
Let us consider the name of the default database is “Employees”. Therefore to know the name of the default database, the database function can be executed in the following way:
The CURRENT_USER() Function in MySQL is used to return the user name and host name for the MySQL account which is used by the server to authenticate the current client.
As of MySQL 4.1.,the CURRENT_USER() function uses the utf8 character set.
CURRENT_USER() function also does not accepts any parameters.
Let us consider the username of MySQL account used by the server to authenticate the current client is ‘root’ and the hostname is ‘localhost’. Therefore to know the username and hostname for the MySQL account used by the server to authenticate the current client, the CURRENT_USER() function can be executed in the following way:
- PHP | MySQL ( Creating Database )
- PHP | MySQL Database Introduction
- MySQL | Database Files
- Database Backup from MySQL
- PHP | Inserting into MySQL database
- MySQL | Ranking Functions
- Mathematical functions in MySQL
- MySQL | Common MySQL Queries
- SQL | Functions (Aggregate and Scalar Functions)
- IFNULL in MySQL
- MySQL | MD5 Function
- MySQL | BIN() Function
- MongoDB vs MySQL
- PHP | MySQL WHERE Clause
- How to get ID of the last updated row in MySQL?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.