Jump to content

Recommended Posts

When i try to enter the password for mysql, it give me "ERROR 1045 <28000>: Access denied for 'user'@'localhost' <using password: YES>

 

What do i do

 

Set permissions to the user if you have already added user to database. or add the user to the database. let me know what you have done with user and database. or trying to connect database without user ?

i dont have a password. I have installed xampp,  this is the first time i am tryin to connect, but the book that i am reading told me to enter the password through cmd( there was a guide for it), but its not working.

 

I was just conecting to mysql, but access denied for that.. so what do i do.. And I have not added any users.

 

and sorry to use this form for my sql.

To create Database in Xampp :

type in your browser (Ie, Mozilla, whatever): localhost

In the left area select: phpmyadmin

There you can create your database an user with the privilages you want.

To Connect to that database in php is something like this:

 

$dbhost = 'localhost'; //host

$dbuser = 'root'; //your username created

$dbpass = 'password'; //the password 4 that user

 

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

 

$dbname = 'whatever';

mysql_select_db($dbname);//your database.

I have tired your way, but error conenctiong to mySql. I am thinking i still havnt connected to my sql though.. or am i not just getting the point..

 

this is the code that i am using to connect mysql

 

<?php // Script 12.3 - create_db.php
/* This script connects to the MySQL server. It also creates and selects the database. */

// Attempt to connect to MySQL and print out messages:
$dbhost = 'localhost'; //host
$dbuser = 'root'; //your username created
$dbpass = 'password'; //the password 4 that user

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

$dbname = 'myBlog';
mysql_select_db($dbname);
//your database.
if ($dbc = @mysql_connect('localhost', 'root', 'pass'))
                
                {

print '<p>Successfully connected to MySQL!</p>';

// Try to create the database:
if (@mysql_query('CREATE DATABASE myblog')) {

	print '<p>The database has been created!</p>';

} else { 
	print '<p style="color: red;">Could 
                    not create the database because:
                    <br />' . mysql_error() . '
                        .</p>';

               
}

// Try to select the database:
if (@mysql_select_db('myblog')) {
	print '<p>The database has been selected.</p>';
} else {
	print '<p style="color: red;">Could not select the database because:<br />' . mysql_error() . '.</p>';
}

mysql_close(); // Close the connection.

} else {

print '<p style="color: red;">Could not connect to MySQL:<br />' . mysql_error() . '.</p>';

}

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.