xxreenaxx1 Posted February 27, 2010 Share Posted February 27, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/193553-mysql-connection-denied/ Share on other sites More sharing options...
jskywalker Posted February 27, 2010 Share Posted February 27, 2010 try entering the correct password? and, what has this to do with "PHP Coding help", as the title of this forum suggests? Quote Link to comment https://forums.phpfreaks.com/topic/193553-mysql-connection-denied/#findComment-1018904 Share on other sites More sharing options...
inversesoft123 Posted February 27, 2010 Share Posted February 27, 2010 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 ? Quote Link to comment https://forums.phpfreaks.com/topic/193553-mysql-connection-denied/#findComment-1018911 Share on other sites More sharing options...
xxreenaxx1 Posted February 27, 2010 Author Share Posted February 27, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/193553-mysql-connection-denied/#findComment-1018914 Share on other sites More sharing options...
inversesoft123 Posted February 27, 2010 Share Posted February 27, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/193553-mysql-connection-denied/#findComment-1018916 Share on other sites More sharing options...
xxreenaxx1 Posted February 27, 2010 Author Share Posted February 27, 2010 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>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/193553-mysql-connection-denied/#findComment-1018925 Share on other sites More sharing options...
PFMaBiSmAd Posted February 27, 2010 Share Posted February 27, 2010 The default password is probably nothing (you would use an empty string as the password value.) You can set a password as documented on the xampp site - http://www.apachefriends.org/en/faq-xampp-windows.html#password1 Quote Link to comment https://forums.phpfreaks.com/topic/193553-mysql-connection-denied/#findComment-1018931 Share on other sites More sharing options...
xxreenaxx1 Posted February 27, 2010 Author Share Posted February 27, 2010 yehh thank you, i just figured it out.. the username name is root... but instead i wrote usename.. and the password is empty.. which i wrote password.. so yeh... Thank you to everyone for helping me Quote Link to comment https://forums.phpfreaks.com/topic/193553-mysql-connection-denied/#findComment-1018932 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.