One approach to build up an association with MariaDB comprises of utilizing the mysql parallel at the order brief.
MYSQL Binary
Survey a model given underneath.
[root@host]# mysql -u root -p
Enter password:******
The code given above interfaces with MariaDB and gives an order brief to executing SQL orders. In the wake of entering the code, an invite message ought to show up demonstrating an effective association, with the form number showed.
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 122323232
Server version: 5.5.40-MariaDB-log
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
The model uses root access, yet any client with advantages can obviously get to the MariaDB incite and perform tasks.
Disengage from MariaDB through the leave order as follows −
mysql> exit
PHP Connection Script
Another approach to interface with and separate from MariaDB comprises of utilizing a PHP content. PHP gives the mysql_connect() work for opening an information base association. It utilizes five discretionary boundaries, and returns a MariaDB interface identifier after a fruitful association, or a bogus on ineffective association. It additionally gives the mysql_close() work for shutting data set associations, which utilizes a solitary boundary.
Syntax
Audit the accompanying PHP association content grammar −
connection mysql_connect(server,user,passwd,new_link,client_flag);
The depiction of the boundaries is given beneath −
Sr.No | Parameter & Description |
---|---|
1 |
server This optional parameter specifies the host name running the database server. Its default value is “localhost:.3036.” |
2 |
user This optional parameter specifies the username accessing the database. Its default value is the owner of the server. |
3 |
passwd This optional parameter specifies the user's password. Its default value is blank. |
4 |
new_link This optional parameter specifies that on a second call tomysql_connect()with identical arguments, rather than a new connection, the identifier of the current connection will be returned. |
5 |
client flags This optional parameter uses a combination of the following constant values −
|
Survey the PHP separation content language structure given beneath −
bool mysql_close ( resource $link_identifier );
In the event that you overlook the asset, the latest opened asset will close. It restores an estimation of valid on a fruitful close, or bogus.
Attempt the accompanying model code to associate with a MariaDB worker −
<html>
<head>
<title>Connect to MariaDB Server</title>
</head>
<body>
<?php
$dbhost = 'localhost:3036';
$dbuser = 'guest1';
$dbpass = 'guest1a';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn ) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($conn);
?>
</body>
</html>
On fruitful association, you will see the accompanying yield −
mysql> Connected successfully