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

Installation tutorial of Python3.4 and MySQL database under Windows7

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "installation tutorial of Python3.4 and MySQL database under Windows7". In daily operation, I believe that many people have doubts about the installation tutorial of Python3.4 and MySQL database under Windows7. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "installation tutorial of Python3.4 and MySQL database under Windows7". Next, please follow the editor to study!

I. MySQL Community Server installation:

1.mysql-5.7.17-win64.zip download

URL: https://dev.mysql.com/downloads/mysql/

Corresponding to the Windows system version, I chose mysql-5.7.17-win64.zip to download. The bottom two ZIP are for testing, so just ignore them.

If you are not logged in, you can choose to download directly.

two。 Extract the ZIP file and unzip it to the directory you want to install.

3. Configure environment variables.

Find the location of the extracted file. The screenshot is as follows:

The value of the variable I configured is D:\ MySQL\ mysql-5.7.17-winx64\ bin. Note that you need to add a semicolon-";" before this. The screenshot is as follows:

4. Configure the my.ini file.

Copy the my-default.ini file to the current directory and rename it my.ini. As follows:

Open the my.ini file to configure as follows (note: the path setting needs to be escaped by the escape character "\", or use the backslash "/" and comment out the last line):

5. Initialize database and configure related information (commands must be executed in the correct order, otherwise initialization will fail)

(1) run the Windows command line cmd as an administrator, and go to the bin directory of the installation directory, as follows:

(2) initialize the data directory:

Enter the command (generate a root user without a password):

Mysqld-initialize-insecure

At this point, a data folder is generated under the mysql folder, with some folders and files in it, indicating that the initialization is successful.

(3) sign up for MySQL service:

Enter the command:

Mysqld-install

The content shown in the following figure indicates that the registration is successful.

(4) start MySQL service:

Enter the command:

Net start mysql

The content shown in the following figure indicates that the startup is successful.

(5) set the password:

Enter the command:

Mysqladmin-u root password password

(6) Log in to mysql with a password:

Enter the command:

Mysql-u root-p

The screenshot is as follows:

At this point, the MySQL configuration is complete.

To exit the MySQL service, use the command:

Exit

To remove the MySQL service, use the command:

Mysqld-remove

II. Connector / Python installation:

The command window (cmd) uses the following commands: easy_install pymysql3

After python3, MySQLdb was replaced by pymysql. Install different connectors depending on the version you use.

Note: this needs to be used after python3.4 is installed. The results are as follows:

three。 test

The test.py program is written as follows:

Import pymysqlconn = pymysql.connect (host='127.0.0.1', port=3306, user='root', passwd='meditation',db='mysql') cursor = conn.cursor () cursor.execute ("SELECT VERSION ()") row = cursor.fetchone () print ("MySQL server version:", row [0]) cursor.close () conn.close ()

Run test.py to view the results, indicating that the configuration was successful.

At this point, the study on the "installation tutorial of Python3.4 and MySQL database under Windows7" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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

Internet Technology

Wechat

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

12
Report