Mysql --- Access denied for user 'test'@'localhost'
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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)
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.
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).
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.
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.
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.
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'));
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.