MySQL: 除了root用戶,拒絕用戶'test'@'localhost'訪問(密碼驗證:是)
<p>我在使用mysql的非root/admin用戶時遇到了問題,我按照下面的步驟創建用戶和權限,請糾正我是否做錯了:</p>
<p>我在<code>RHEL 5.7 64bit</code>上安裝<code>mysql</code>,安裝包如下,一旦我完成了<code>rpm install</code>,我們就完成了<code>rpm install</code>,我們就完成了<code>rpm install</code>,我們就完成了<code>rpm install</code>,我們就會</p>
<ol>
<li>使用<code>mysql_install_db</code>建立mysql資料庫,然後</li>
<li>啟動mysql服務,然後</li>
<li>使用<code>mysql_upgrade</code>也會對伺服器進行操作。 </li>
</ol>
<p>在這個過程之後,我可以使用<code>root</code>登錄,但用非root用戶無法登入伺服器:</p>
<pre class="brush:php;toolbar:false;">[root@clustertest3 ~]# rpm -qa | grep MySQL
MySQL-client-advanced-5.5.21-1.rhel5
MySQL-server-advanced-5.5.21-1.rhel5
[root@clustertest3 ~]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[root@clustertest3 ~]# ls -ld /var/lib/mysql/mysql.sock
srwxrwxrwx 1 mysql mysql 0 Nov 30 11:09 /var/lib/mysql/mysql.sock
mysql> CREATE USER 'golden'@'%' IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON * . * TO 'golden'@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT USER(),CURRENT_USER();
---------------- ----------------
| USER() | CURRENT_USER() |
---------------- ----------------
| root@localhost | root@localhost |
---------------- ----------------
1 row in set (0.00 sec)
[root@clustertest3 ~]# mysql -ugolden -p
Enter password:
ERROR 1045 (28000): Access denied for user 'golden'@'localhost' (using password: YES)</pre>
<p>這就是我遇到的問題,有沒有解決方法? </p>