472,374 Members | 1,523 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,374 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 6998
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...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

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.