ssh ubuntu@xxx.xxx.xx.xx
mysql -uroot -p
而后输入密码便可在本地终端中登陆mysqlhtml
这是ubuntu中安装Mysql过程没有设置密码,致使没法登陆python
mysql -uroot -p use mysql; update user set password=password("123456") where user="root"; flush privileges; exit
Python爬虫过程当中若是像网页中插入html会提示sql错误,咱们须要对sql语句进行转义,这样就很方便的把sql语句进行转义:mysql
import MySQLdb sql = MySQLdb.escape_string(sql)
可是转义后能够存入数据库,那么怎么取出html文本呢ios
//须要安装HTMLParser sudo pip install HTMLParser html_parser = HTMLParser.HTMLParser() html_content = html_parser.unescape(html_content)
参考:sql