473,320 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Access denied for user: username@%

red
I know this is probably a faq but it is hard to search for this exact
problem.
When I put this on a php page:
<?
$link = mysql_connect("localhost", "cardini", "password")
or die("Could not connect : " . mysql_error());
echo "Connected successfully\n";
mysql_select_db("articles") or die("Could not select database");
$sql = 'CREATE TABLE image( id mediumint( 8 ) unsigned NOT NULL
AUTO_INCREMENT ,'
. ' masterid mediumint( 8 ) unsigned NOT NULL default \'0\','
. ' filedata blob NOT NULL ,'
. ' PRIMARY KEY ( id ) ,'
. ' KEY master_idx( masterid ) ) TYPE = MYISAM ';
mysql_query($sql);
db(mysql_error());
?>
This is the result:
Connected successfully

[Access denied for user: 'cardini@%' to database 'articles']

How can it connect successfully to the database, yet with the same user
and password, fail to connect ?

or maybe a better question would be: How did 'localhost' get changed to
'@%' ?

Jul 17 '05 #1
3 7069
red
red wrote:
I know this is probably a faq but it is hard to search for this exact
problem.
When I put this on a php page:
<?
$link = mysql_connect("localhost", "cardini", "password")
or die("Could not connect : " . mysql_error());
echo "Connected successfully\n";
mysql_select_db("articles") or die("Could not select database");
$sql = 'CREATE TABLE image( id mediumint( 8 ) unsigned NOT NULL
AUTO_INCREMENT ,'
. ' masterid mediumint( 8 ) unsigned NOT NULL default \'0\','
. ' filedata blob NOT NULL ,'
. ' PRIMARY KEY ( id ) ,'
. ' KEY master_idx( masterid ) ) TYPE = MYISAM ';
mysql_query($sql);
db(mysql_error());
?>
This is the result:
Connected successfully

[Access denied for user: 'cardini@%' to database 'articles']

How can it connect successfully to the database, yet with the same user
and password, fail to connect ?

or maybe a better question would be: How did 'localhost' get changed to
'@%' ?

I figured out what that cryptic messge meant- the user had not been
granted the appropriate privilege, in this case the create privilage.
I was in the middle of granting privilages when I got distracted by the
debate.
Jul 17 '05 #2
Hi there, Red.
Will you please be so kind as to help me out with your solution - I have
the same problem and I am totally new to this.

Regards,
Deon H
Jul 17 '05 #3
red
Deon H wrote:
Hi there, Red.
Will you please be so kind as to help me out with your solution - I have
the same problem and I am totally new to this.

Regards,
Deon H

The problem confused me because my username and password successfully
connected to the database but didn't work when I tried to create a
table. But this does make sense because to create a table you not only
have to have a username and password to connect to the database, you
must have the right to create a table within that database.

I'm using windowsxp, this is how I grant rights:

1)Go to the command prompt. There is a link in the start menu.
2)Change the directory to the directory of mysql. The letters cd are
used to change the directory. On my computer, I write:
cd c:\\mysql\bin
The prompt changes to c:\\mysql\bin>
3)logon to the root account of mysql . If your mysql is set up properly,
simply typing
mysql
without a username and password should give you an access denied
message. If it lets you in without giving you an access denied message,
then you still have a default user which should be deleted.

To access the root account type mysql -u root -p
It will then ask you for your root password and let you in

4) To grant rights, use the grant command. If I want to grant
"myusername" with a password of "mypassword" the rights that most users
are allowed to have to "mydatabase" I would use:

grant select, insert, update, delete, index, alter, create, drop on
mydatabase.* to myusername identified by 'mypassword';

Notice the single quotes around the password. Those are the only quotes
in the whole command.

That fixed the problem for me
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ryan Schefke | last post by:
------=_NextPart_000_0077_01C34C8B.2B90C960 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit ..I just sent this out to the win32 distribution list but no one has...
8
by: John | last post by:
Hello. I am currently working through a book on Dreamweaver and using PHP. I am having a little trouble with setting up the database though. I have php 4.2.3 and MySQL 4.0.20a. I am running...
2
by: adnan alsamari | last post by:
Hi, I can only access mysql through the root by typing mysql -u root -p. But when I use any other user to connect to mysql I get the access denied error message. Mysql is installed on windows xp. ...
0
by: c.verma | last post by:
I have a web based (forms based authentication) asp.net application that uses .NET remoting. It has web.config.remoting with all the required settings in it. As soon as it tries to access the...
0
by: robgallen | last post by:
I'm having a wierd issue trying to launch a robocopy process via a web form. To cut a long story short, it works fine when I run it from the server it is hosted on, but when I access the site from...
8
by: ajos | last post by:
hi frnds, im trying to convert my servlets database configuration from ms access to mysql database.however im getting some error like no driver found exception. to verify this error ive...
1
by: zlf | last post by:
Hello my website has role based access, and user without specific role assigned cannot access specific page in website. When the user try to access a page who has not been granted to access, the...
2
by: =?Utf-8?B?RWRkaWU=?= | last post by:
Here is my scenario for a problem I can't solve. I am hosting a 3.5 WCF service in IIS on Windows Server 2003. The service works fine with the WCF test client in Visual Studio 2008 and from an...
2
by: =?Utf-8?B?bXVyYWRqYW1lcw==?= | last post by:
Yes, sorry I tried to make it clear in the original question that I want to get the user token of the service - ie. the account the service is running under. I know services don't have user tokens...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.