Jump to content
Larry Ullman's Book Forums

Trying To Connect To The Mysql Server

Recommended Posts

I'm currently at step 5 on p.440. 

I got the "Enter password" prompt, but when I entered a password, I got the following response:


ERROR 1045 <28000>: Access denied for user 'root'@'localhost' <using password: Y


It was really weird the way it was cut off like that. But try as I might, I could only expand the command prompt window vertically, not horizontally. So I'm not 100% sure what the messages are.


So I tried using "yes" as a password and got this response:


ERROR 1045 <28000>: Access denied for user 'root'@'localhost' <using password: N


What am I doing wrong?

Link to comment
Share on other sites

Sorry for the confusion here! I wouldn't worry at all about the "YES" being wrapped like that. It's just a matter of the size of the terminal window and has no impact on the functionality. 


I'm not sure what's going on the second time. Do you know what the proper MySQL password is? It's almost certainly not "yes". 

Link to comment
Share on other sites

Depending upon how you installed MySQL and on what operating system, there may or may not be a password set already. 


Earlier you specifically referenced page 440, and the steps there are just logging into MySQL. They aren't trying to set the password. 

Link to comment
Share on other sites

I'm actually on p.350. It said something about testing connection username and password by using them in the MySQL client, which I thought was a reference to p. 438.


Anyhow, this is my code for mysqli_connect.php:


<!doctype html>

<html lang="en">
   <meta charset="utf-8">
   <title>Connect to MySQL</title>
<?php // Script 12.1 - mysqli_connect.php
/* This script connects to the MySQL database. */
// Attempt to connect to MySQL and print out messages:
if ($dbc = mysqli_connect('localhost', 'username', 'password', 'myblog')) {
   print '<p>Successfully connected to the database!</p>';
   mysqli_close($dbc); // Close the connection.
 } else {
   print '<p style="color: red;">Could not connect to the database.</p>';


But when I bring up its page, I get the following:



Warning: mysqli_connect(): (HY000/1045): Access denied for user 'username'@'localhost' (using password: YES) in C:\xampp\htdocs\tutorialspoint\mysqli_connect.php on line 12 
Could not connect to the database.

As far as installing MySQL, I've just installed XAMPP on Windows 7 Professional.

I thought XAMPP already has MySQL. Or have I misunderstood something?

Edited by hfcnew
Link to comment
Share on other sites

Yes, XAMMP includes MySQL. From the FAQ, it looks like XAMPP does not set a root user password: https://www.apachefriends.org/faq_windows.html


You may or may not want to do that. But then you'll need to create a MySQL user with the username "username" and a password of "password" (or a different user and then use those appropriate values later).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...