MySQL mailuser not being allowed in

I created a new user with the following line from the Linode guide "EMail with PostFix, DoveCot and MySQL", the MySQL section, step 4.

GRANT SELECT ON mailserver.* TO 'mailuser'@'127.0.0.1' IDENTIFIED BY 'asdf';

When I inspect the user table, I get the following:

mysql> select host, user, select_priv from user;
+-----------+------------------+-------------+
| host      | user             | select_priv |
+-----------+------------------+-------------+
| localhost | root             | Y           |
| localhost | mysql.session    | N           |
| localhost | mysql.sys        | N           |
| localhost | debian-sys-maint | Y           |
| 127.0.0.1 | mailuser         | N           |
+-----------+------------------+-------------+
5 rows in set (0.00 sec)

Shouldn't the select_priv field hold a "Y" for 'mailuser'?

When I exit mysql and try to re-enter as 'mailuser' I get the following error message.

[email protected]:~$ sudo mysql -u mailuser -p
Enter password:
ERROR 1045 (28000): Access denied for user 'mailuser'@'localhost' (using password: YES)

I am wondering about MySQL asserting "localhost' here, especially when I've explicitly used '127.0.0.1' as the host of mailuser.

Does this indicate that I've done something wrong with my hosts file?

The /etc/hosts file current has the following lines (with XXX to obscure the actual ip address).

127.0.0.1 localhost
XXXIPv4XXX adonax.adonax.com adonax
XXXIPv6XXX adonax.adonax.com adonax

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

If I create the MySQL user with a host of "localhost" instead of "127.0.0.1" I am able to get into MySQL as mailuser, and run select queries, despite the "select_priv" field for mailuser holding a "N". Why is this?

I would like to conform to the guide and use [email protected] instead of [email protected], if possible. There are commands further on in this guide that might be affected if I start changing things, I fear.

I should mention, I tried editing the first line of the hosts file to read the following:

127.0.0.1 localhost.localdomain localhost

But this doesn't seem to make any difference.

Is there anything special that has to be done after editing the hosts file to make it operative? For example, exit and reenter the Linode? Shut down and reboot the Linode?

2 Replies

MySql sees connections coming from localhost.

So what you want is:

GRANT SELECT ON mailserver.* TO 'mailuser'@'localhost' IDENTIFIED BY 'asdf';

Yes, entering the user with "localhost" as the host works. I was just worried that it might cause problems down the road to diverge from the guide's instructions, and wanted to check before proceeding.

The guide should be corrected!

I would do so myself, but I don't think I should touch the document until/unless I actually get my email server working. I'll revisit the issue of updating documentation and guides down the road.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct