Quantcast
Channel: MySQL Forums - Install & Repo
Viewing all articles
Browse latest Browse all 7239

Setting up a connection with a database (1 reply)

$
0
0
I want to set up a connection with a database I've created on my computer using a file looking like this:

<?php
$hostname = "hostname";
$username = "username";
$password = "password";
$connection = mysql_connect($hostname, $username, $password)
or die("Could not open connection to database");
mysql_select_db("db_name", $connection)
or die("Could not select database");
?>

But I'm not quite sure about how to repalce "hostname". Is a host something I need to create myself and if so how do I do that? I run mysql on ubuntu and use the terminal to work with it.
Or is the host something that already exist and if so how do I find out what it's name is?

Also, how do I create a user? Do I use mysqladmin or do I log in to mysql as root and use create user?

Viewing all articles
Browse latest Browse all 7239

Trending Articles