List:General Discussion« Previous MessageNext Message »
From:Michael Stassen Date:February 9 2004 2:29am
Subject:Re: Error creating database
View as plain text  

I've copied the list on this reply.  I hope you don't mind.  It's a good 
idea to keep the discussion on the list.  There are a lot of experts 
there, so the speed and quality of your answers is improved when you 
send to the list rather than to an individual.  Plus, others may benefit 
from your question and its answers.

I think you've asked beginner questions, not stupid questions.  It takes 
some getting used to at first, but mysql users are separate from Mac 
users.  Think of them as separate systems, even though one runs on the 
other.  When you ran mysql_install_db, you got 4 mysql users, 
root@localhost, root@hostname, ''@localhost, and ''@hostname, where 
"hostname" is the name of your Mac.  The mysql root user is the admin, 
the anonymous user ('') can't do much.  If you don't specify a mysql 
username to the client, mysql tries to use your Mac username, but it has 
to exist in the user table.  So, if you simply enter `mysql` at the 
command line, you are trying to log into mysql as martyray@localhost, 
but since that user doesn't exist in the mysql user table yet, you wind 
up as the anonymous user.

The fix is to log into mysql as root (or use mysqladmin) and create the 
martyray@localhost user and give yourself appropriate privileges.  A 
prudent course might be to leave database creation to root, and give 
yourself all privilieges on your dbs.  Assuming you've followed the 
instructions to set a password for root@localhost, you could do the 

in the terminal, start the mysql client:
   mysql -u root -p	#you'll be prompted for the password

in the mysql client:
   mysql> CREATE DATABASE dogs;	#root creates the db
   mysql> GRANT ALL ON dogs.* to martyray@localhost
       -> IDENTIFIED BY 'your_mysql_password';

That last command does 3 things

1) Creates the mysql user martyray@localhost, if it doesn't already exist.

2) Sets martyray@localhost's password to the string after IDENTIFIED BY.

3) Gives martyray@localhost all rights to the dogs database.

After that, you should be able to enter `mysql -p` to log into mysql as 

I recommend the online manual together with just trying things out. 
Here are a couple relevant pages to start:



Marty Ray wrote:
> Thanks a lot Michael! That explains some of the wording in the error 
> messages '@localhost'. I have a ready stupid question though. How did I 
> get logged in as anonymous? I thought I was logged in as 
> martyray@localhost? Doesn't that happen when I log onto my Mac? Surely I 
> don't have to log in as root all the time?
> Thanks again...
> Marty
> On Feb 7, 2004, at 10:20 PM, Michael Stassen wrote:
>> mysql wrote:
>>> HI everyone:
>>> I am using a dual 800 MHz power mac G4 in which I have installed 
>>> MySQL.  When ever I try to create a new database in MySQL, I receive 
>>> the following error
>>> "mysql> create database dogs;
>>> ERROR 1044 (42000): Access denied for user: ''@'localhost' to 
>>> database 'dogs'"
>> You are logged in as the anonymous (no username) user ''@'localhost'. 
>> The anonymous user doesn't have privilieges to do much (nor should 
>> he).  In fact, many people delete the anonymous user.
>>> Can anyone assist me in how to fix this error? Thanks.
>>> Mark
>> Once you've followed the directions to set a password for the root 
>> user, log in as root to create databases.
>>  mysql -u root -p
>> Michael
>> -- 
>> MySQL General Mailing List
>> For list archives:
>> To unsubscribe:

Error creating databasemysql8 Feb
  • Re: Error creating databaseMichael Stassen8 Feb
RE: Error creating databaseMike Mapsnac8 Feb
Re: Error creating databaseMichael Stassen9 Feb