Tool==》Deployment==》Configuration
File==》Settings==》Project:xx==》python interpreter
Run==》Edit Configuration==》New python configuration
Note: is special here It should be noted that if you want to debug Django in pycharm, you need to set the formal parameters to: runserver 0:8000
This sentence can be rewritten as: In order to debug remote code locally, the Django project needs Start at 0.0.0.0:8000.
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'computers', 'USER': 'root', 'PASSWORD': '123', 'HOST': '192.168.28.128', 'PORT': '3306' } }
Note: Here HOST can be used when running directly on the remote end. localhost", but you need to change it to the ip of the remote server when debugging the remote end with pycharm. Otherwise, the following error will occur:
django.db.utils.OperationalError: ( 1698, "Access denied for user 'root'@'localhost'")
(1) Modify the my.cnf file (ubuntu The following address is:/etc/mysql/mysql.conf.d/mysqld.cnf)
Modify if necessary and add if not:
bind-address=0.0.0.0
(2) Restart the mysqld service:
systemctl restart mysqld
(3) Link mysql
mysql -u root -p
(4) Use database mysql
use mysql;
(5) Configuration permissions
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;1
Parameter explanation:
"." -- --All resources and all permissions
"‘root’@%" — root represents the user name % represents all access addresses (you can also use a unique address to replace it, only an address can be accessed).
IDENTIFIED BY ‘root’, this root refers to the access password.
WITH GRANT OPTION allows cascading authorization
(6) It is important to refresh the system permission related table data
flush privileges;
(7) Check whether the addition is successful
select Host, User from user;
##(8) Verify remote access
Remote host address:
mysql -u root -p -h
The above is the detailed content of How to remotely debug Pycharm and MySQL database authorization issues. For more information, please follow other related articles on the PHP Chinese website!