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