How to use mysql-connector connection to use MySQL
Most people do not understand the knowledge points of this article "how to use mysql-connector connection to use MySQL", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to use mysql-connector connection to use MySQL" article.
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; the above is about "how to use mysql-connector connection to use MySQL" this article, I believe we all have a certain understanding, I hope the content shared by the editor will be helpful to you, if you want to know more about the relevant knowledge, please follow the industry information channel.