Two ways to connect to a mysql Database.
Method 1.One can connect to a mysql database using the command line client .Below is the syntax for connecting to using command line client .
Method 2:The other method of connecting to a mysql database is the use of a server side scripting language like php or perl
I will demonstrate using
<?php // Connects to your Database if(!defined('INCLUDE_CHECK')) die("not allowed to execute directly"); $host="127.0.0.1"; $username="root"; $password=""; // Mysql password $db="essaybay"; $link=mysql_connect($host,$username,$password) or die(mysql_error()); mysql_select_db($db,$link); mysql_query("SET names UTF8"); ?>
Note:Incase the mysql database is installed on the same computer that you are running the code for exampe if you are using a wamp server, you can either use 127.0.0.1 or localhost as the values for host.Replace the root with the database username and password with your password.Then select the database.
My next post is about selecting and displaying data retrieved from a DB SELECT command.Check it here…