473,385 Members | 1,764 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,385 software developers and data experts.

Access denied for user ''@'localhost'

I have some experienced with MySQL on Windows, but now I'm trying with mac os, I can access the mysql from the terminal, but i can view the databases but i can't modify or create a new one. I get this message:
Expand|Select|Wrap|Line Numbers
  1. Welcome to the MySQL monitor.  Commands end with ; or \g.
  2. Your MySQL connection id is 4
  3. Server version: 5.0.37 MySQL Community Server (GPL)
  4.  
  5. Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  6.  
  7. mysql> create database newland_tours;
  8. ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'newland_tours'
  9. mysql> 
Please somebody help me with this, I can pay you if you can through paypal,
Thank u
Sep 26 '07 #1

✓ answered by pbmods

Heya, Markodilore.

To log into MySQL, use this:
Expand|Select|Wrap|Line Numbers
  1. /usr/local/mysql/bin/mysql -u root -p
  2.  

19 140375
pbmods
5,821 Expert 4TB
Heya, Mark. Welcome to TSDN!

I went ahead and split your post into its own thread so as to avoid hijacking the original poster's thread.
Sep 27 '07 #2
r035198x
13,262 8TB
I have some experienced with MySQL on Windows, but now I'm trying with mac os, I can access the mysql from the terminal, but i can view the databases but i can't modify or create a new one. I get this message:

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.0.37 MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create database newland_tours;
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'newland_tours'
mysql>

Please somebody help me with this, I can pay you if you can through paypal,
Thank u
Your user account does not have create database priviledges.
Sep 27 '07 #3
pbmods
5,821 Expert 4TB
Heya, Markodilore.

Did you set up a root account for your MySQL database?

In the terminal type:
Expand|Select|Wrap|Line Numbers
  1. > mysqladmin -u root password 'root password goes here'
  2.  
And then to invoke the MySQL client:
Expand|Select|Wrap|Line Numbers
  1. > mysql -u root -p
  2.  
Sep 27 '07 #4
Thanks very much for answering me guys, but I don' now if i created an account. this is how i access the mysql screen troough the terminal, please tell me what i'm doing wrong:

Last login: Thu Sep 27 11:28:12 on console
Welcome to Darwin!
Marko-Dilore-Computer:~ markodilore$ sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
Password:
Starting MySQL database server
Marko-Dilore-Computer:~ markodilore$ cd /usr/local/mysql
Marko-Dilore-Computer:usr/local/mysql markodilore$ > mysqladmin -u root password '55555'
-bash: mysqladmin: Permission denied
Marko-Dilore-Computer:usr/local/mysql markodilore$ > mysqladmin -u root password 'orlando'
-bash: mysqladmin: Permission denied
Marko-Dilore-Computer:usr/local/mysql markodilore$ > mysqladmin -u root password ''
-bash: mysqladmin: Permission denied
Marko-Dilore-Computer:usr/local/mysql markodilore$ >

Where the first password('55555') is the one i tried to set up and the second one('orlando') is the one i used to install new programs on my mac, then i just tried to left it blank. I also tried to change the name root for 'user' and 'markodilore' but it didn't work either
Sep 27 '07 #5
pbmods
5,821 Expert 4TB
Heya, Markodilore.

Looks like your MySQL installation has incorrect permissions.

Execute the following commands:
Expand|Select|Wrap|Line Numbers
  1. > cd /usr/local/mysql
  2. > sudo chown -R mysql data
  3. > sudo chgrp -R mysql data
  4. > sudo scripts/mysql_install_db --user=mysql
  5. > sudo bin/mysqladmin -u root password 'password for root goes here'
  6.  
Sep 27 '07 #6
Thanks a lot, man, for helping me with this. Those commands you told me to insert seemed to work:
Expand|Select|Wrap|Line Numbers
  1. Last login: Thu Sep 27 19:24:27 on console
  2. Welcome to Darwin!
  3. Marko-Dilore-Computer:~ markodilore$ cd /usr/local/mysql
  4. Marko-Dilore-Computer:/usr/local/mysql markodilore$  sudo chown -R mysql data
  5. Password:
  6. Marko-Dilore-Computer:/usr/local/mysql markodilore$  sudo chgrp -R mysql data
  7. Marko-Dilore-Computer:/usr/local/mysql markodilore$  sudo scripts/mysql_install_db --user=mysql
  8. Password:
  9. Installing all prepared tables
  10. 070927 20:17:27 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql-5.0.37-osx10.3-powerpc/data/ is case insensitive
  11. Fill help tables
  12. 070927 20:17:27 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql-5.0.37-osx10.3-powerpc/data/ is case insensitive
  13.  
  14. To start mysqld at boot time you have to copy support-files/mysql.server
  15. to the right place for your system
  16.  
  17. PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
  18. To do so, start the server, then issue the following commands:
  19. ./bin/mysqladmin -u root password 'new-password'
  20. ./bin/mysqladmin -u root -h Marko-Dilore-Computer.local password 'new-password'
  21. See the manual for more instructions.
  22.  
  23. NOTE:  If you are upgrading from a MySQL <= 3.22.10 you should run
  24. the ./bin/mysql_fix_privilege_tables. Otherwise you will not be
  25. able to use the new GRANT command!
  26.  
  27. You can start the MySQL daemon with:
  28. cd . ; ./bin/mysqld_safe &
  29.  
  30. You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
  31. cd sql-bench ; perl run-all-tests
  32.  
  33. Please report any problems with the ./bin/mysqlbug script!
  34.  
  35. The latest information about MySQL is available on the web at
  36. http://www.mysql.com
  37. Support MySQL by buying support/licenses at http://shop.mysql.com
  38. Marko-Dilore-Computer:/usr/local/mysql markodilore$  sudo bin/mysqladmin -u root password '55555'
But I think now that i have made theese changes I should log on in a different way, because I keep getting this message:
Expand|Select|Wrap|Line Numbers
  1. Marko-Dilore-Computer:/usr/local/mysql markodilore$ /usr/local/mysql/bin/mysql
  2. Welcome to the MySQL monitor.  Commands end with ; or \g.
  3. Your MySQL connection id is 2
  4. Server version: 5.0.37 MySQL Community Server (GPL)
  5.  
  6. Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  7.  
  8. mysql> create database newland_tours;
  9. ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'newland_tours'
How do you think i should access MySQL now? Again, thank you.
Sep 28 '07 #7
pbmods
5,821 Expert 4TB
Heya, Markodilore.

To log into MySQL, use this:
Expand|Select|Wrap|Line Numbers
  1. /usr/local/mysql/bin/mysql -u root -p
  2.  
Sep 29 '07 #8
IT WORKED, IT WORKED, IT WORKED, THANK YOU VERY MUCH, MAN!!!!!!
Tell me where to send the money
Sep 29 '07 #9
pbmods
5,821 Expert 4TB
Heya, Markodilore.

You're most welcome. Take the money and go have a good time in my honor.

Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)
Sep 29 '07 #10
Heya, Markodilore.

Looks like your MySQL installation has incorrect permissions.

Execute the following commands:
Expand|Select|Wrap|Line Numbers
  1. > cd /usr/local/mysql
  2. > sudo chown -R mysql data
  3. > sudo chgrp -R mysql data
  4. > sudo scripts/mysql_install_db --user=mysql
  5. > sudo bin/mysqladmin -u root password 'password for root goes here'
  6.  
My situation is similar. But I can only login as an anonymous user -- '@'localhost.
There are 2 dbs only.

I execute the command above and I stuck at sudo bin/mysqladmin -u root password 'password for root goes here'

my command: sudo ./bin/mysqladmin -u root password '' (no password)
but it complains 'Access denied; you need the SUPER privilege for this operation'. What? I think I got all permission of mac tiger......
Jan 7 '08 #11
My situation is similar. But I can only login as an anonymous user -- '@'localhost.
There are 2 dbs only.

I execute the command above and I stuck at sudo bin/mysqladmin -u root password 'password for root goes here'

my command: sudo ./bin/mysqladmin -u root password '' (no password)
but it complains 'Access denied; you need the SUPER privilege for this operation'. What? I think I got all permission of mac tiger......
mysql version - 5.0.45..... I think that is why super privilege won't work....
Jan 7 '08 #12
I've got a problem in the same vein, but since nothing I've tried works, I strongly suspect myself of a PEBKAC error :)

The scenario is this: a form for logging in, which does a SELECT and an UPDATE, and a form for registering, which should do an INSERT. The login form works flawlessly, the register form fails with the following output:
Warning: mysql_query() [function.mysql-query]: Access denied for user 'emacovei'@'localhost' (using password: NO) in /home/studs/2004/emacovei/html/php/register.php on line 39

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/studs/2004/emacovei/html/php/register.php on line 39
mysql_query error: Access denied for user 'emacovei'@'localhost' (using password: NO)

Guilty code (the last line causes the problems, as shown by the "or die" output above):
Expand|Select|Wrap|Line Numbers
  1.         if( hasUserName( $safeUserName ) ){
  2.             appendToErrorMessage( "User name already exists in the database." );
  3.             return false;
  4.         } else {
  5.             $selectQuery = "INSERT INTO Users (
  6.         ID , UserName , UserPwd , LastLogin , LastTheme )
  7. VALUES( NULL, '$safeUserName', '$safeUserPwd', '" . date( "Y-m-d H:i:s", time() ) . "', '" . DEFA_THEME . "' );";
  8.  
  9. echo $selectQuery . "<br />";
  10.             $dbReply = mysql_query( $selectQuery ) or die( "mysql_query error: " . mysql_error() );
  11.  
I've checked my priorities when writing the code for the login form, and I'm OK in that department. This is why I'm leaning towards this being just a stupid error.

A $selectQuery example would be:
INSERT INTO Users ( ID , UserName , UserPwd , LastLogin , LastTheme ) VALUES( NULL, 'aaa', 'aaa', '2008-06-06 22:53:06', 'ThemeTriTri.css' );
Jun 6 '08 #13
pbmods
5,821 Expert 4TB
Heya, Strika.

You need to establish a connection to the MySQL database server (using mysql_connect()) before you can execute a query.
Jun 7 '08 #14
Heya, Strika.

You need to establish a connection to the MySQL database server (using mysql_connect()) before you can execute a query.
Heya, pbmods.

The database connection is established via a wrapper function to mysql_connect, the same one I'm calling from the login form. Plus, opening the database doesn't die on me; essentially, it's all going great until I call mysql_query().

I didn't include the full connection code, because, as stated, it was verified via the login action (and via an independent script, and via the "or die"s). Based on that, I'll take a leap of faith and say it's correct, but anyhow, here it is:

Expand|Select|Wrap|Line Numbers
  1. /**function getMySQLConnection()
  2. Returns: resource $connection */
  3. function getMySQLConnection()
  4. /* throws ConnectionError, AND sets the error label. */{
  5.     if( $connection = mysql_connect( DB_SERVER, DB_NAME, DB_PASSWD ) )
  6.     {
  7.         return $connection;
  8.     } else {
  9.         appendToErrorMessage( "Could not open connection to users' database. Error: " . mysql_error() );
  10.         throw new ConnectionError( "Could not open connection to users' database. Error: " . mysql_error() );
  11.     }
  12. } // getMySQLConnection
This is part of utils.php
In the register function, above the code posted upthread, I've got:


Expand|Select|Wrap|Line Numbers
  1. $mySqlConnection = getMySQLConnection();
  2. mysql_select_db( DB_DATABASE, $mySqlConnection ) or die( "Database Selection Error: " . mysql_error() );
getMySQLConnection() doesn't throw exceptions, and mysql_select_db doesn't die. Based on that, I'm looking for the error in the "else".
Jun 7 '08 #15
pbmods
5,821 Expert 4TB
Can you verify that the connection code is being run?

The reason I ask is that PHP is reporting the 'access denied' error is being triggered by mysql_query(), not mysql_connect(), which would lead me to believe that at the time your script attempts to call mysql_query(), the connection has not been established.

PHP will attempt to establish a connection using the default values specified in php.ini, which is usually maybe a Username, and that's it. I'm thinking that's what happened based on the "using password NO" part.
Jun 9 '08 #16
You might laugh at this.

I took up pbmods' advice, and tried to mess around the connection code. Around it, not with it. I've:

* put echoes in getMySQLConnection, one right before returning the connection, the other before throwing the exception.
* commented out:
$mySqlConnection = getMySQLConnection(); and put
$mySqlConnection = mysql_connect( "...", "...", "..." ) or die( "Connection Error: " . mysql_error());
with the params hardcoded.
* went in Notepad++ and search-highlighted every occurrence of $mySqlConnection - just in case I have a typo.
* copy/pasted the SELECT from login.php, hardcoded the username and tried to print on page.
U-oh! Same error as from the INSERT. So I look between mysql_select_db and selectQuery. The only notable thing there was:

Expand|Select|Wrap|Line Numbers
  1.  if( hasUserName( $safeUserName ) ){
Thing was, the script was pretty much having its cake and eating it, too. All connection, db open, etc. code was correct.

But hasUserName:
- connects to the db,
- executes "SELECT UserName FROM Users WHERE UserName = '" . $safeUserName . "';",
- CLOSES THE CONNECTION
- and returns true or false.

After calling it, there's no more connection.

I moved the connecting on the "else" branch, and that's it.
Jun 10 '08 #17
cl578
2
@pbmods
I know that the initial post is from 2 years ago, but I would like to say Thank You so much for answering this question. This answer really helped me and as a result, I am now a member of the website, which is not something I normally do...

Thank You, again!
Sep 26 '09 #18
tg3793
1
@pbmods
I would like to thank you SO MUCH for posting this information and caring so much about helping others with this. Now, over two years later I am able to make great use of this.

I am not a "spring chicken" when it comes to IT by any means. And I'd like to think that I am in the top one or two percent of people that I've ever known when it comes to tracking down the answer to IT related problems. Would you believe it took me about three hours of focussed effort to find that simple answer you gave here.

That's right; several dozen websites (including blogs and forums), doing searches through the html version of the MySQL users manual, and even a question that I posted to the #mysql IRC channel (which no one ever answered).


And for the future edification of anyone else that might come to this, I had to make a very slight modification to the answer that was given here because I am on a Windows XP machine. I installed vTiger which automatically installed MySQL within it's installation. So I typed the following:

C:\Program Files\vtigercrm-5.1.0\mysql\bin\mysql -u root -p

From there it prompted me for the root password and I was home free. ..Again, thank you thank you thank you.
Dec 11 '09 #19
guys, I had a same problem and I was searching for this solution, thank god, you guys saved my temper as well ... thanks it works
Oct 21 '10 #20

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Steve | last post by:
Hi, Yesterday I signed up for another dedicated linux server with the hosting company I use and I am having problems getting MySQL 4.1.3 working on it. I've tried just about everything I can...
3
by: Ian | last post by:
The beginning of my assembly that I am getting the access error from looks like this. ********************************* Imports System.EnterpriseServices Imports System Imports...
3
by: vincentw56 | last post by:
This is the first time I have tried this. What we have is a com object the generates keys. A developer here wrote a .Net wrapper in C# for this com object. I am trying to call her dll wrapper...
4
by: Fabian von Romberg | last post by:
Hi, I have installed Sql Reporting Services on 2 machines, one is WIN 2000 PRO and the other one is WIN 2000 ADV. SERVER. When I try to access a report using the webbrowser, I get the following...
12
by: Chad Crowder | last post by:
Hi all, I hope someone can give me a hand, because I'm out of ideas. I keep getting this message: Access to the path "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET...
6
by: ASP.Confused | last post by:
I have an ASP.NET page writtein in VB that uses ADODB. I just had to force-install MDAC 2.8 after I tried to rollback to 2.6 (my web host uses this, and I wanted to be compatible with them.) I...
0
by: ASP.Confused | last post by:
The old message looked a little stale, so I am re-posting it here. Anybody have any ideas of what I could do?!? The previous responses to this question are below. If you want to look at the...
1
by: karthi84 | last post by:
hi, when i tried to open a new excel spread sheet from my web form i got this access denied page. can any one help me in solving this problem. Server Error in '/sk/ContractInvoice'...
8
by: Jeremy Ames | last post by:
I am trying to move an application from my system to a new test system. I really should have tried an easier program first, but I didn't really have a chance. My application was originally written in...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.