|
[root@localhost ~]# /usr/local/mysql51/bin/mysql --defaults-file=/usr/local/mysql51/my.cnf -u root -h 192.168.0.33 -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'192.168.0.33' (using password: YES)
[root@localhost ~]# /usr/local/mysql51/bin/mysql --defaults-file=/usr/local/mysql51/my.cnf -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@localhost ~]# /usr/local/mysql51/bin/mysql --defaults-file=/usr/local/mysql51/my.cnf -u root -h 127.0.0.1 -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@localhost ~]# /usr/local/mysql51/bin/mysql --defaults-file=/usr/local/mysql51/my.cnf -u root -h 192.168.0.33 -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 51
Server version: 5.1.49-log Source distribution
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql> use mysql;
Database changed
mysql> select host,user,password from user;
+-----------------------+----------+-------------------------------------------+
| host | user | password |
+-----------------------+----------+-------------------------------------------+
| localhost | root | *0A5C9A5D1ECD39865185673B394BB0E7DE48E730 |
| localhost.localdomain | root | |
| 127.0.0.1 | root | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
| localhost | | |
| localhost.localdomain | | |
| % | mpsearch | *45927E5E752FECB140B2DDD63A05705AFAFB20CD |
| 192.168.0.33 | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+-----------------------+----------+-------------------------------------------+
7 rows in set (0.00 sec)
结论:
1、针对root用户,-h 127.0.0.1参数,MySQL会把它转化成localhost;
2、用户名同为root,不同主机权限可是设置不同的密码。 |
|