使用grant all privileges on *.* to ppnie@localhost identified by 'ppnie123' with grant option; 创建新用户后
使用 mysql -uppnie -pppnie123 登陆数据库的时候报如下错误;
ERROR 1045 (28000): Access denied for user 'ppnie'@'localhost' (using password:
YES)
在网上搜到的解决方法是 修改密码
# mysql -u root 123456
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER=‘ppnie' or host='localhost';//把空的用户密码都修改成非空的密码就行了。
mysql> FLUSH PRIVILEGES;
mysql> quit
但是重新登陆后仍然报错,于是ping localhost ,发现主机名未ping 通

原来是域名未定义
修改方法:修改 C:\Windows\System32\drivers\etc\hosts
将 127.0.0.1 localhost 添加进去即可

重启MySQL服务,然后登陆数据库,登陆成功,问题解决