Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the concept of mysql-connector?

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report