Collections:
Connect to MySQL Server with User Account in MySQL
How To Connect to MySQL Server with User Accounts in MySQL?
✍: FYIcenter.com
If you want to connect a MySQL server with user account name and password, you need to call mysql_connect() with more parameters like this:
$con = mysql_connect($server, $username, $password);
If your MySQL server is provided by your Internet service company, you need to ask them what is the server hostname, port number, user account name and password. The following tutorial exercise shows you how to connect to a MySQL server, on host "localhost", at port "8888", with user account "dev", and with password "iyf":
<?php
$con = mysql_connect('localhost:8888', 'dev', 'iyf');
if (!$con) {
print("There is a problem with MySQL connection.\n");
} else {
print("The MySQL connection object is ready.\n");
mysql_close($con);
}
?>
If all parameters are correct, you should get a good connection object as shown in the following output:
The MySQL connection object is ready.
⇒ Accessing MySQL Server through Firewalls in MySQL
⇐ Connect to MySQL Server with Port Number in MySQL
2017-11-25, 2517🔥, 0💬
Popular Posts:
Is SQL Server Transact-SQL case sensitive? No. Transact-SQL is not case sensitive. Like the standard...
What Are Date and Time Functions in MySQL? MySQL offers a number of functions for date and time valu...
How To Verify a User name with SQLCMD Tool in SQL Server? The quickest way to verify a user name in ...
Where to find tutorials to answer some frequently asked questions on Microsoft SQL Server Transact-S...
Where to find SQL Server database server tutorials? Here is a collection of tutorials, tips and FAQs...