Home > Database > Mysql Tutorial > body text

How to remotely debug Pycharm and MySQL database authorization issues

PHPz
Release: 2023-05-30 18:46:15
forward
1361 people have browsed it

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'
    }
}
Copy after login

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
Copy after login

(2) Restart the mysqld service:

systemctl restart mysqld
Copy after login

(3) Link mysql

mysql -u root -p
Copy after login

(4) Use database mysql

use mysql;
Copy after login

(5) Configuration permissions

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;1
Copy after login

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;
Copy after login

(7) Check whether the addition is successful

select Host, User from user;
Copy after login

How to remotely debug Pycharm and MySQL database authorization issues

##(8) Verify remote access

Remote host address:

mysql -u root -p -h
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!