Python3 reads MySQL-Front MYSQL password, python3mysql-front

Source: Internet
Author: User

Python3 reads MySQL-Front MYSQL password, python3mysql-front

Preface

The same routine is coming again. Continue to try again.Read sensitive information from the configuration fileThis is the turnMySQL-Front.

MySQL-Front on an open source mysql management tools, official website http://www.mysqlfront.de /.

Path of the configuration file:

The MySQL-Front configuration file is stored in the user directory and the environment variable is % appdata %.

In Windows 7, the storage path is:

C:\Users\%user%\AppData\Roaming\MySQL-Front\Accounts.xml

The xml file Accounts. XML stores all important information and the password is not encrypted by default. The last time I forgot the password of the mysql root User, I opened this file and immediately recovered the password,

This is not the benefit of encryption. → _ → However, there are always people who want to harm the hacker. They still need to protect these important information so as not to be read by the bad guys.

Format XML

The content in Accounts. xml is compressed into a row. You need to format it into a nice-looking format. You can search for these online tools.

The formatted content of Accounts. xml is as follows:

<?xml version="1.0" encoding="utf-8"?><accounts version="1.1.0"> <default>127.0.0.1</default> <account name="127.0.0.1"> <lastlogin>42847.9391816088</lastlogin> <manualurl version="5.0.22-community-nt"></manualurl> <connection>  <database></database>  

PyQuery, a tool for python to process XML and HTML

For the purpose of practice, I want to use the XML standard library of python to process XML, but the built-in python provides several methods: xml. sax xml. dom xml. minidom

There is also xml. parsers. expat, too many options, or decide to usePyQueryPyQuery is a jquery-style xml parsing and processing Library Based on lxml.

Lxml is a very important library of python. It is known that pandas, BeautifulSoup, and so on are partially functional dependent on lxml.

Run the following command to install the SDK:

pip install pyquery

After reading the tutorial, I can write out the code.

Python3 reads the MySQL-Front password:

# -*- coding: utf-8 -*-"""Created on 2017-04-22 22:53:35@author: codegay"""import osfrom pyquery import PyQuery as pyqxmlpath = os.environ['appdata']+r'\MySQL-Front\Accounts.xml'root = pyq(filename=xmlpath)for r in root('connection').items(): print("----------------------------------------------") print('host:',r('host').text()) print('username:',r('user').text()) print('password:',r('password').text())

Output after running the Code:

----------------------------------------------host: 127.0.0.1username: rootpassword: root----------------------------------------------host: 127.0.0.1username: daqinpassword: daqin

The above is all the content of this article. I hope this article will help you in your study or work. I also hope to provide more support to the customer's home!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.