Connect To MySQL

I know that the following allows me to connect to a MySQL server:

mysqli_connect('localhost', 'root', 'password');

How do I connect without a root username and password?

I want to connect using a database name, database username, and database password. I think WordPress does this?

If your working on your localhost via phpMyAdmin simply click privileges from the main window when it loads and add a new user with all or only privileges you want it to have.

On a production server depending on the control panel your host uses you would do the same only via the MySQL management area.

I know how to add users and passwords. I want to know how to use PHP to connect to specific databases and the usernames/passwords assigned to the databases.

I’m looking through WordPress’s wp-config file, and I notice it shows a specific database, and the database’s username and password. When I go through WordPress’s install, it never asks for my root information. I’m going through a tutorial about MySQL and PHP and it only shows me how to connect with my root username and password.

You connect in exactly the same way, just replace the credentials.

Do you mean



$con = mysql_connect ('localhost', 'root', 'password');

mysql_select_db("Database you want to use", $con);