How Do I Find the Database Name in WordPress?

When you want to find the database name in WordPress, you can use the wpdb class. To do this, you will first need to create a new object using the wpdb class. The following code will create an object called bloginfo that contains the database name and username of the blog you are working with:

var bloginfo = new WPdb();

bloginfo.set_blog( ‘http://WordPress.org’ );

bloginfo.set_user( ‘username’ );

bloginfo.set_password( ‘password’ );

The bloginfo object can then be used to find the database name:

bloginfo.get_database()

The above code will return the name of the database that the blog is using.