pymysql.err.OperationalError: (1045, "Access denied for user 'iiiii'@'?.?.?.?' (using password: YES)")
先去查看你的表:
select user,host from mysql.user;
看看是不是有用户名为空的用户,有的话干掉它。
因为当你设置了用户a:’user0‘@‘%’
然后你的用户表里面有用户名为空的用户b:‘’@‘localhst’
当你用用户a登陆时会与b造成冲突。所以干掉没有用户名的用户,
delete from mysql.user where user='';
第二步 :
检查一下你的远程登陆账号密码在本机上能不能登陆,能登陆的情况下,确定是不是:不要密码也能登陆(不输密码也能登陆就去删掉这个用户重新创建,貌似再次创建的时候不能用刚删除的那个用户名创建,创建过程见分界线下面)。修复这些问题,你应该就能登陆了的。
以上是我解决我的问题的过程,若以上没解决你的问题,请参照以下:
Several possible causes :
- the user doesn't have permission to connect remotely
- MYSQL is in stopped state at remote server
- 3306 port is not allowed in remote server
- Your IP is not allowed to access the remote server using http
Check if all of these are true , you should be able to connect
https://stackoverflow.com/questions/30317723/how-to-connect-to-remote-mysql-db-in-yii2
=========我=是分界线======好==吧==其实==我==也是========等号=============
1.创建用户
创建user01,只能本地访问
create user user01@'localhost' identified by 'password';
创建user02,可以远程访问
create user user02@'%' identified by 'password'
2.授权
授予user01管理test的全部权限
grant all privileges on test.* to user01;
授予user02查看权限,并修改密码
grant select on *.* to 'user02'@'%' identified by 'password';
授予所有权限
GRANT ALL PRIVILEGES ON *.* TO userName@"%" IDENTIFIED BY "uerPassword";