How to connect database inside the cPanel using Python?
Asked Answered
O

1

7

I would like to connect inside the database of cPanel using Python and insert some new data. I can write SQL and Python code to do the insertion. However, but don't know how to connect with cPanel.

I have the website address (say, www.myuscanadahouse.com), cPanel username, cPanel password and database name inside the phpMyAdmin in the cPanel. Some tutorial or starting code in Python will be helpful. I've seen this page https://pypi.python.org/pypi/pycpanel/0.1.2#id6, but I wasn't able to make it work here.

I get the following error while connecting with the MySQL database:

_mysql_exceptions.OperationalError: (1045, "Access denied for user'buildersa'@'47.124.85.71' (using password: YES)")
Overage answered 16/5, 2016 at 7:14 Comment(0)
S
0

If you have a connection error, it's likely MySQL is bound to localhost. Assuming you're using a Linux server:

On your remote machine, edit /etc/mysql/my.cnf

Find bind-address=127.0.0.1, edit it to bind-address=0.0.0.0, or just comment out.

Restart MySQL

service mysql restart

Read more

reference: stackoverflow & digitalocean

If you will have an authentication error, connect to your MySQL (via ssh terminal) and make new user with grand privileges.

CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'a_pass';

GRANT ALL PRIVILEGES ON *.* TO 'new_user'@'localhost' WITH GRANT OPTION;

CREATE USER 'new_user'@'%' IDENTIFIED BY 'a_pass';

GRANT ALL PRIVILEGES ON *.* TO 'new_user'@'%' WITH GRANT OPTION;

FLUSH PRIVILEGES;

Then it's not a bad idea to restart MySQL again:

service mysql restart

and try again with your new user credentials

reference DigitalOcean

Hope I helped, Good Luck





Siret answered 16/5, 2016 at 9:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.