LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Mysql --- Access denied for user 'test'@'localhost' (http://www.linuxquestions.org/questions/linux-server-73/mysql-access-denied-for-user-test%40localhost-659526/)

permalac 07-31-2008 10:35 AM

Mysql --- Access denied for user 'test'@'localhost'
 
Hello,

I'm trying to install zabbix on my sandbox server and I'm stacked on the mysql stuff.




9024:20080731:173122 **** Enabled features ****
9024:20080731:173122 SNMP monitoring: YES
9024:20080731:173122 WEB monitoring: YES
9024:20080731:173122 Jabber notifications: YES
9024:20080731:173122 **************************
9024:20080731:173122 Failed to connect to database: Error: Access denied for user 'zabbix'@'localhost' (using password: YES) [1045]



(Bold is mine)


I keep having the same error message if I access through $mysql -u zabbix -p




Has anyone here solved this issue before?


Many thanks.

trickykid 07-31-2008 01:06 PM

Well, is this user setup in the database and did you configure it with a password on the localhost?

permalac 08-01-2008 03:51 AM

Quote:

Originally Posted by trickykid (Post 3232327)
Well, is this user setup in the database and did you configure it with a password on the localhost?

Yes, there is a mysql user called 'zabbix' , with all the rights on the database 'zabbix'.

I can access the mysql through the shell, but it does not use the password.
Code:


[root@ocata4888 exploits]# mysql -u zabbix
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 410 to server version: 5.0.27

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

mysql> set password = password("z4bbix");
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
mysql>


Don't understand, because if I set the password on the zabbix config file to 'nothing' it does not log in when I do /etc/init.d/zabbix start

:/


What should I check?

Thanks.

permalac 08-01-2008 03:55 AM

I have also re set the zabbix password, but nothing.


Code:

# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 413 to server version: 5.0.27

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

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)

mysql> update user set password=PASSWORD("z4bb1x") where User='zabbix';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
# mysql -u zabbix -p
Enter password:
ERROR 1045 (28000): Access denied for user 'zabbix'@'localhost' (using password: YES)



What else can I do?


Thanks.

sleddog 08-01-2008 08:26 PM

Check the syntax for MySQL 5:

http://dev.mysql.com/doc/refman/5.0/...-password.html

As MySQL root user try:

mysql>SET PASSWORD FOR 'zabbix'@'localhost' = PASSWORD('z4bb1x');

permalac 08-04-2008 04:09 AM

Quote:

Originally Posted by sleddog (Post 3233811)
Check the syntax for MySQL 5:

http://dev.mysql.com/doc/refman/5.0/...-password.html

As MySQL root user try:

mysql>SET PASSWORD FOR 'zabbix'@'localhost' = PASSWORD('z4bb1x');


Thanks, but I can't.


mysql> SET PASSWORD FOR 'zabbix'@'localhost' = PASSWORD('z4bb1x');
ERROR 1133 (42000): Can't find any matching row in the user table
mysql> select User,Password from user;
+----------------+------------------+
| User | Password |
+----------------+------------------+
| root | 7db8c0e24ed909d4 |
| root | 7db8c0e24ed909d4 |
| | |
| | |
| 20203dmediasql | 1a0831a150e52962 |
| zabbix | 107342234bff3223 |
| test | 378b243e220ea493 |
+----------------+------------------+
7 rows in set (0.00 sec)

mysql>



I really don't understand it.


Thanks.

datopdog 08-04-2008 04:14 AM

Try
Code:

SET PASSWORD FOR 'zabbix' = PASSWORD('z4bb1x');

Phil-B 08-04-2008 08:22 AM

From the error message you posted it's not finding zabbix@localhost in your users table so you can't set a password for it nor can you log in using it.

Try creating zabbix@localhost, setting a password for it and logging in.

chrism01 08-04-2008 08:26 AM

See the examples here: http://dev.mysql.com/doc/refman/5.0/en/grant.html
Note that user accts are defined by where they are allowed to login from, so zabbix@localhost is a different user/acct to zabbix@myhost (for example).

checkmate3001 08-04-2008 09:04 AM

You know... I had a similar problem with my mysql... for the life of me I can't remember what the problem was. I know I eventually had to recreate the user and redo the password... I wish I took notes.

trickykid 08-04-2008 09:12 AM

Can't anyone notice the obvious?

Code:

mysql> update user set password=PASSWORD("z4bb1x") where User='zabbix';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0

Try changing that line to:

Code:

update user set Password=password('z4bb1x') where User='zabbix';
flush privileges;

Make sure it then prints out something like this:

Code:

Rows matched: 1  Changed: 1  Warnings: 0
Previously it never changed anything cause PASSWORD should be all lowercase and password column is actually Password, not all lowercase. Also, only put single ticks around the password, you had it somewhat correct but the following syntax I gave you should work with MySQL 5.x.

jschiwal 08-04-2008 09:17 AM

Look at "select Host, User, Password FROM user";

There are two things that can trip you up. If you are on host "permalac", your domain name may be included when you log in, so you may need an entry for "permalac.zybbix" for example. This should match the denied message that you see. However in your case, the user is logging in from 'localhost' and this isn't the problem.

Another thing to look for is an earlier matching entry that has a different password or no password. I think it it occurs first in the User table, that is what will be tried. Anyway, look for an additional entry for the 'zabbix' user that has wild cards or the hostname of the computer that mysql is running on.

Two things I thought I'd mention. You might want to delete the anonymous account. Also, you don't need to su to root to log into mysql as the root user. The -u option will do that.

permalac 08-05-2008 02:45 AM

Hey, many thanks, some of you were on the good way.


The thing was that I was trying to log in with 'zabbix'@'localhost' , and the only existing zabbix was 'zabbix'@'' , and is not the same. What I've done is create another zabbix, I know is not the best way, but I've learned something about mysql, and this is the point.



Code:

insert into user (Host,User,Password) values ('localhost','zabbix',PASSWORD('z4bb1x'));

rs232c 01-18-2012 04:05 PM

My fix
 
Maybe this will help someone with the same issue:

I fixed this by going into /etc/zabbix/zabbix_server.conf. It had set a random password (I believe during setup). zabbix-server apparently doesn't take the password from any of the other files, it pulls it directly from here.

# Database host name
# Default is localhost

DBHost=localhost

# Database name
# SQLite3 note: path to database file must be provided. DBUser and DBPassword are ignored.
DBName=zabbix

# Database user

DBUser=zabbix

# Database password
# Comment this line if no password used

DBPassword=pass

shijobaby 03-05-2013 06:30 AM

http://answerforu.com/2011/06/22/acc...ser-mysql-php/


All times are GMT -5. The time now is 02:03 AM.