When migrating mysql database, run the program found that nginx and uWSGI are configured correctly, but I could not open the site, read the log files, errors are found:
django.db.utils.OperationalError: (1044, "Access denied for user 'lcp'@'%' to database 'work_blog'")
Mysql database to see this realized now only the root account, it did not lcp this. So it is necessary to add this user and password and appropriate permissions, the following is a generic command:
-u root MySQL - the p- the CREATE the USER ' myuser ' @ ' localhost ' IDENTIFIED BY ' mypassword ' ; # log on locally the CREATE the USER ' myuser ' @ ' % ' IDENTIFIED BY ' mypassword ' ; # telnet quit; MySQL -u myuser - the p- # test is successfully created # privileges to modify the grant permissions on the database. * to username @ log on by host IDENTIFIED ' password ' ; flush privileges; # refresh system permissions table
service mysql restart
Take the test as an example:
1 # enter MySQL 2 MySQL -u the root - P . 3 # local access account . 4 the CREATE the USER ' Test ' @ ' localhost ' the IDENTIFIED BY ' ln122920 ' ; . 5 # remote access . 6 the CREATE the USER ' Test ' @ ' % ' the IDENTIFIED BY ' ln122920 ' ; 7 # all local authority authorized test users havetestDB
all permissions to the database 8 Grant * All privileges ON testDB to. ' test ' @ 'localhost ' IDENTIFIED by ' ln122920 ' ; 9 # remote all authorized, authorized test users havetestDB
all permissions to the database 10 Grant All privileges ON testDB * to. ' test ' @ ' % ' IDENTIFIED by ' ln122920 ' ; 11 # refresh permission 12 flush privileges;
If you need only a part of the authority, then:
grant select,update on testDB.* to 'test'@'localhost' identified by 'ln122920'; flush privileges; # 刷新权限
Finally, restart it: Service restart MySQL