0

I installed MySQL with pip install mysql-connector-python.

But for connecting in Python I don't know what password to use.

mysqldb=mysql.connector.connect(host="localhost",user="",password="",database="")

4
  • 1
    Did you install mysql database server too? Commented Feb 23, 2022 at 16:23
  • The password is by default root Commented Feb 23, 2022 at 16:24
  • 3
    The password is not defined by the database adapter, it is defined by the MySQL server. Commented Feb 23, 2022 at 16:24
  • How install mysql for python? i use this command but get error pip install MySQL-python, Commented Feb 23, 2022 at 16:51

1 Answer 1

0

Don't use password, just use host. https://dev.mysql.com/doc/connector-python/en/connector-python-connectargs.html

(Btw. this is just connecting package, you need MySql server too - https://pypi.org/project/MySQL-python/)

Sign up to request clarification or add additional context in comments.

3 Comments

Could you explain what you mean with "just use host"? On the page you linked to I can find the following: "Authentication with MySQL typically uses a username and password."
@Matthias Look at Table 7.1 - Default values
I don't get it. user and password have no default values, so they are clearly missing if I don't provide them. One could omit host if it's running on localhost (aka 127.0.0.1), but one has to provide user and password.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.