The connection uses MySQL "MySQL binary":
You can create a MySQL database using mysql binary at the command prompt.
example
Here is a simple example to connect to a MySQL server from the command prompt:
[Root @ host] # mysql -u root -p
Enter password: ******
This will give you mysql> command prompt where you will be able to execute SQL commands. Here are the results of the above command:
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 2854760 to server version: 5.0.9
Type 'help;' or '\ h' for help. Type '\ c' to clear the buffer
In the above example we have used as the root user, but you can use other users.
Each user will be able to perform all the SQL operations allowed for the user.
You can disconnect from a MySQL database using the command every time out in the mysql> prompt.
mysql> exit
bye
MySQL connection using PHP Script:
PHP provides mysql_connect () function to open a database connection.
This function takes five parameters and returns a link identifier on the success of MySQL,
or FALSE on failure.
Syntax:
connection mysql_connect(server,user,passwd,new_link,client_flag);
Parameter Description
server Optional - The name of the host running the database server. If not specified, the default value is localhost: 3036.
user Optional - The username to access the database. If not specified, the default is the user name that has a process server.
password Optional - passwords of users accessing the database. If not specified, the default is a blank password.
new link new_link Optional - If a second call is made to mysql_connect () with the same arguments, no new connection will be established, but the identifier of the connection that has been opened will be restored.
client flags Optional - A combination of the following constants: - MYSQL_CLIENT_SSL - Use SSL encryption
MYSQL_CLIENT_COMPRESS - Use compression protocol
MYSQL_CLIENT_IGNORE_SPACE - Allow space after function names
MYSQL_CLIENT_INTERACTIVE - Allow interactive timeout seconds of inactivity before closing the connection
You can disconnect from MySQL database anytime using another mysql_close PHP function (). This function takes a single parameter that connection is returned by mysql_connect () function
Syntax:
mysql_close bool (resource $ link_identifier);
If the resource is not specified, the last opened database is closed.
This function returns true if it closes the connection is successful if it does not return false.
Example:
Try the following examples to connect to a MySQL server:
<Html>
<Head>
<Title> Connecting MySQL Server </ title>
</ Head>
<Body>
<? Php
$ Dbhost = 'localhost: 3036';
$ Dbuser = 'guest';
$ Dbpass = 'guest123';
$ Conn = mysql_connect ($ dbhost, $ dbuser, $ dbpass);
if (! $ conn)
{
die ("Could not connect:". mysql_error ());
}
echo 'Connected successfully';
mysql_close ($ conn);
?>
</ Body>
</ Html>
.


