当我创build一个新的Mysql用户时,使用此用户和密码login是不可能的。 只有我创build一个没有密码的用户,我才可以login。
例如:
mysql -u root -phererootpass grant all privileges on mydb.* to testuser@'%' identified by '' with grant option; grant all privileges on mydb.* to testuser2@'%' identified by 'mypass' with grant option; FLUSH PRIVILEGES; exit; mysql -u testuser #<<< work fine mysql -u testuser2 -pmypass #<<< fail to login ERROR 1045 (28000): Access denied for user 'testuser2'@'localhost' (using password: YES) </code>
我在Red Hat v5上使用Mysql 5.0
请build议莫斯塔尔
您所设置的只允许您从本地主机以外的所有其他服务器进行连接。 你也需要运行这个
grant all privileges on mydb.* to testuser2@'localhost' identified by 'mypass' with grant option;
然后记得冲洗你的特权。
尝试设置环境variablesMYSQL_PWD?
导出MYSQL_PWD ='mypass'
mysql -u testuser2 -p
根据我的经验,将密码作为CLI的一部分传递是一个坏主意。 (它会显示在你的进程列表中,任何用户都可以看到'top')