MySQL Forums
Forum List  »  Connector/Python

create database and user via a python script ran as sudo
Posted by: odile LAMbert
Date: April 02, 2022 11:22AM

Hello
I am writing a python script which I runas sudo. The goal of the python script is to create a user and a database for this user.
I get the following message.
>>> mydb = mysql.connector.connect( host = "localhost", user = user, password = "mypassword")
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/mysql/connector/connection_cext.py", line 236, in _open_connection
self._cmysql.connect(**cnx_kwargs)
_mysql_connector.MySQLInterfaceError: Access denied for user 'root'@'localhost'

This happens just after the installation of the package mysql server. Thus I have not yet granted any privileges to root.

Is this the cause of the problem? should I write a shell script to install all my sql packages and grant the privileges??
I thank you for your help.

Options: ReplyQuote


Subject
Written By
Posted
create database and user via a python script ran as sudo
April 02, 2022 11:22AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.