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:
- How to add Image to MySql database using Servlet and JDBC
- MySQL | Common MySQL Queries
- PHP | MySQL Database Introduction
- PHP | MySQL ( Creating Database )
- PHP | Inserting into MySQL database
- MySQL | Database Files
- Database Backup from MySQL
- MINUTE(), MICROSECOND() and HOUR() functions in MySQL
- MySQL | Ranking Functions
- Mathematical functions in MySQL
- LCASE() or LOWER() Functions in MySQL
- MySQL | LEAD() and LAG() Function
- Java Servlet and JDBC Example | Insert data in MySQL
- Difference between MySQL and MS SQL Server
- Difference between MySQL and SQLite
- Difference Between MySQL and MariaDB
- Difference between Cassandra and MySQL
- Difference between CouchDB and MySQL
- What is Collation and Character Set in MySQL?
- Difference between Neo4j and 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.