Before proceeding for this you need to create a database with available Control Panels. Once you have created a database, there are a few ways you can connect to it :
mysql -u DBUSERNAME -h DBSERVER -p DBNAME
with the following replacements of the bolded terms above:
~ Replace DBSERVER with the correct database servername for your site.
~ Replace DBUSERNAME with your own mysql username.
mysql -u mike -h db.joesmith.com -p mikedb
If you don’t know your MySQL Username or MySQL Databasename, go here.
You will then be prompted for your MySQL password. If you don’t know what that is, go here to set it to something that you will remember.
If you use preferences set in a .my.cnf file, the connection command would be much shorter, just:
Once at the MySQL prompt, you can then issue SQL commands directly to the MySQL server. For correct SQL syntax, see the MySQL Manual.
- To connect from a PHP script, just put this in your file:
using the same substitutions for the bold terms as above, plus substituting DBPASSWORD with your own mysql password.
mysql_connect(“db.joesmith.com”, “mike”, “secret”);
- To connect from a perl script, put this in your file:
$database = “DBNAME”;
$hostname = “db.YOURDOMAIN”;
$port = “3306″;
$username = “DBUSERNAME”;
$password = ‘DBPASSWORD’;
$dsn = “DBI:mysql:database=$database;host=$hostname;port=$port”;
$dbh = DBI->connect($dsn, $username, $password) or die(“Could not connect!”);
$sql = “SELECT * FROM mytable”;
$sth = $dbh->prepare($sql);
while(($column1, $column2) = $sth->fetchrow_array)
print “C1 = $column1, C2 = $column2n”;
where DBNAME, DBUSERNAME, and DBPASSWORD are your database name, database username and database password, and where YOURDOMAIN is your website’s domain name with no “www.” in front, for example, “mysite.com”, or if you are not hosting your own domain name with us, then “mysite.modwest.com”.
Like this post ?
Share on your Social Networking Profile ( Facebook, Twitter & Google+ ) and get a flat 10% Recurring discount on our VPS Hosting and Dedicated Servers.
Email us the shared link at : firstname.lastname@example.org or speak to our live chat operator now, by clicking on the “Live Chat” Scroller on the left-hand side of this page and we will provide you with the discount Coupon right away!