13

Well, this is what I can see:

select host, user from mysql.user;

+-----------+------------------+
| host      | user             |
+-----------+------------------+
| %         | me               |
| 127.0.0.1 | root             |
| ::1       | root             |
| localhost |                  |
| localhost | debian-sys-maint |
| localhost | root             |
| ubuntu    |                  |
| ubuntu    | root             |
+-----------+------------------+

I entered as root and would like to change password for user 'me'.

SET PASSWORD FOR 'me'@'%' = PASSWORD('letmein');
Query OK, 0 rows affected (0.00 sec)

Well, no rows affected as we can see.

As for trying to access, the result is as follows:

Access denied for user 'me'@'localhost' (using password: YES)
michael@ubuntu:/var/www/cgi-bin$ 

So, it mentions localhost, not %.

Could you suggest me how to change the password for 'me' and explain what % is?

4

2 に答える 2

13

You need to set password for localhost:

SET PASSWORD FOR 'me'@'localhost' = PASSWORD('letmein');

FLUSH PRIVILEGES;

% means remote hosts can login to MySQL server from any other server whereas localhost means you can login to MySQL server only from same machine.

于 2012-10-17T10:12:45.920 に答える
2

'%' mean you can login into database from any host connected to those database. You also define your localhost as host if you want to access database from localhost.

to change your password:

SET PASSWORD FOR 'me'@'%' = PASSWORD('letmein');

and don't forget execute:

FLUSH PRIVILEGES;

to commit your change. Please look at MySql Account Management.

UPDATE:

As on your user table I not found username with host = localhost you must create this user first by (here to add user):

Grant all privileges on *.* to me@'localhost' identified by 'letmein';
flush privileges;
于 2012-10-17T10:15:13.087 に答える