标签:bsp round for col 测试 权限 art localhost 设置
迁移mysql数据库,运行项目的时候发现nginx和uWSGI都配置正确,可就是网站打不开,看了log文件,发现错误:
django.db.utils.OperationalError: (1044, "Access denied for user ‘lcp‘@‘%‘ to database ‘work_blog‘")
看到这意识到mysql数据库现在只有root账户,并没lcp这个。所以需要增加这个用户,并设置密码和相应权限,下面是一个通用命令:
mysql -u root -p CREATE USER ‘myuser‘@‘localhost‘ IDENTIFIED BY ‘mypassword‘; #本地登录 CREATE USER ‘myuser‘@‘%‘ IDENTIFIED BY ‘mypassword‘; #远程登录 quit; mysql -u myuser -p #测试是否创建成功 # 权限修改 grant 权限 on 数据库.* to 用户名@登录主机 identified by ‘密码‘; flush privileges; # 刷新系统权限表
service mysql restart
拿test作为示例:
1 # 进入mysql 2 mysql -u root -p 3 # 本地访问账户 4 CREATE USER ‘test‘@‘localhost‘ IDENTIFIED BY ‘ln122920‘; 5 # 远程访问 6 CREATE USER ‘test‘@‘%‘ IDENTIFIED BY ‘ln122920‘; 7 # 本地全部授权,授权test用户拥有testDB
数据库的所有权限 8 grant all privileges on testDB.* to ‘test‘@‘localhost‘ identified by ‘ln122920‘; 9 # 远程全部授权,授权test用户拥有testDB
数据库的所有权限 10 grant all privileges on testDB.* to ‘test‘@‘%‘ identified by ‘ln122920‘; 11 # 刷新权限 12 flush privileges;
如果你只需要部分权限,则:
grant select,update on testDB.* to ‘test‘@‘localhost‘ identified by ‘ln122920‘; flush privileges; # 刷新权限
最后重启一下:service mysql restart
标签:bsp round for col 测试 权限 art localhost 设置
原文地址:https://www.cnblogs.com/cpl9412290130/p/11923595.html