Home>Article>Database> How to remotely debug Pycharm and MySQL database authorization issues

How to remotely debug Pycharm and MySQL database authorization issues

PHPz
PHPz forward
2023-05-30 18:46:15 1288browse

1. Pycharm configuration

1. Deployment configuration

Tool==》Deployment==》Configuration

How to remotely debug Pycharm and MySQL database authorization issues

How to remotely debug Pycharm and MySQL database authorization issues

2. python interpreter

File==》Settings==》Project:xx==》python interpreter

How to remotely debug Pycharm and MySQL database authorization issues

3 , Run/Debug Configuration

Run==》Edit Configuration==》New python configuration

How to remotely debug Pycharm and MySQL database authorization issues

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.

2. Mysql database authorization issues

1. settings.py

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'")

2. mysql remote database authorization

(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;

How to remotely debug Pycharm and MySQL database authorization issues

##(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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete