Log in to MySQL with Python inbound Performance Logs

Source: Internet
Author: User
Tags kali linux

1. Under Windows Python code import mysqldb error

Import MySQLdb

Importerror:no module named MySQLdb


2.Python Connect to database, note to specify character set

Import MySQLdb

db = MySQLdb.connect (host = ' 192.168.1.101 ', user = ' user ', passwd = ' password ', db= ' PERFDB ', charset= ' UTF8 ')

cursor = Db.cursor ()


3.Kali Linux turn on MySQL remote access

Kali default MySQL only allows native access, so you need two changes, one is/etc/mysql/my.conf to set the IP address, but in MySQL to authorize what users can remotely access what database. If the connection is not successful, check the iptables.

[Email protected]:~/desktop# vi/etc/mysql/my.cnf

Add in [Mysqld] (the IP is the IP of the MySQL server)

Bind-address = 192.168.1.101

Then enter MySQL, authorized user can password password from any IP remote access

mysql> use MySQL;

Database changed

Mysql> Grant all privileges on * * to [e-mail protected] '% ' identified by ' password ';


4. Quickly erase MySQL's in-table data. This command is equivalent to deleting a table and creating the same new table, so it is extremely fast.

TRUNCATE TABLE name;


5. Delete the first line of the log file because the first row is the header row

Sed-i ' 1d '



This article is from the "RYANSCN" blog, make sure to keep this source http://ryanscn.blog.51cto.com/2725212/1604024

Log in to MySQL with Python inbound Performance Logs

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.