Get the App
SLTechnology News&Howtos  ›  Database  › 

What is the concept of mysql-connector?

Shulou Source: shulou.com Published: 2022-05-31 10:44:39 10月04日 Update

This article mainly introduces the relevant knowledge of "what is the concept of mysql-connector". The editor shows you the operation process through an actual case, and the operation method is simple, fast and practical. I hope this article "what is the concept of mysql-connector" can help you solve the problem.

"mysql-connector" is the official drive provided by mysql, which can be used to connect. Using mysql;, you can use the "pip install mysql-connector" command to install, and use "import mysql.connector" to test whether the installation is successful.

The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.

What is mysql-connector?

Use mysql-connector to connect using MySQL, mysql-connector is the official drive provided by MySQL.

We can use the pip command to install mysql-connector:

Python-m pip install mysql-connector

Test whether mysql-connector is installed successfully using the following code:

Demo_mysql_test.py:import mysql.connector

Execute the above code, if there is no error, it indicates that the installation is successful.

Note: if your MySQL is version 8.0, the password plug-in verification method has changed. The previous version is mysql_native_password,8.0 and the version is caching_sha2_password, so you need to make some changes:

Modify the my.ini configuration first:

[mysqld] default_authentication_plugin=mysql_native_password

Then change the password by executing the following command under mysql:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY' New password

Examples are as follows:

Create a database connection

You can use the following code to connect to the database:

Demo_mysql_test.py:import mysql.connector mydb = mysql.connector.connect (host= "localhost", # database host address user= "yourusername", # database user name passwd= "yourpassword" # database password) print (mydb) on "what is the concept of mysql-connector", thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Tags: Data database version concept success code command password knowledge official industry driver test driver different practical host content address Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Docker MySQL Shulou Information vpn