Jump to content

Recommended Posts

I am learning mysql using an example.

 

According to the guidelines, I created a table and I was trying to access it with the following code:

<?php
define("MYSQLUSER", "php24sql");
define("MYSQLPASS", "");
define("HOSTNAME", "localhost");
define("MYSQLDB", "smithside");

$connection = @new mysqli(HOSTNAME, MYSQLUSER, MYSQLPASS, MYSQLDB);
if ($connection->connect_error) {
die('Connect Error: ' . $connection->connect_error);
}
else {
    echo 'Successful connection to MySQL <br />';
    if ($result = $connection->query("SHOW TABLES")) {
        $count =$result->num_rows;
        echo "Tables: ($count)<br />";
        while ($row = $result->fetch_array()) {
            echo $row[0]. '<br />';
            }
        }
    }

 

I got the following error:

Connect Error: Access denied for user 'php24sql'@'localhost' (using password: NO)

 

At first, I was sure it's the password, so I changed to "no password" using phpMyAdmin, but I still get the above error.

 

Here is what I see at phMyAdmin:

Users having access to "smithside"

User Host Type Privileges Grant Action

php24sql % global SELECT, INSERT, UPDATE, DELETE No Edit Privileges

php24sql localhost global SELECT, INSERT, UPDATE, DELETE No Edit Privileges

root linux global ALL PRIVILEGES Yes Edit Privileges

root localhost global ALL PRIVILEGES Yes Edit Privileges

 

 

Can you log into the MySQL console?

 

Windows:

->cmd

->cd (to your mysql directory) ex. wamp is C:/wamp/bin/mysql/mysql(version)/bin/

->mysql -u php24sql -p;

 

it will prompt you for a password.  If you are not using one, hit enter and it will let you in, or throw an error.

 

I hope this was clear for you. 

 

*note, if you are using wampserver, you can just choose the mysql console from the tray.

@ jcbones, the console is very hard to understand for people comming from Microsoft's world  :D

@YigalB, open up your phpmyadmin application, go to "SQL" tab (on the top), and copy/paste this code:

GRANT ALL PRIVILEGES ON `db_base` . * TO 'php24sql'@'localhost';

Can you log into the MySQL console?

 

Windows:

->cmd

->cd (to your mysql directory) ex. wamp is C:/wamp/bin/mysql/mysql(version)/bin/

->mysql -u php24sql -p;

 

it will prompt you for a password.  If you are not using one, hit enter and it will let you in, or throw an error.

 

I hope this was clear for you. 

 

*note, if you are using wampserver, you can just choose the mysql console from the tray.

 

Thanks!

I am using XAMPP.

I followed your guide lines and got:

ERROR 1045 (28000): Access denied for user 'php24sql'@'localhost' (using password: YES)

 

Then I re-entered the original password - and it worked! Thanks !

 

I am not sure what happen, because I marked "no password" and "go" at phpMyAdmin, but now it seems the need for password is still there.

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.