连接MySQL
1 | import pymysql |
插入单条数据
1 | try: |
插入多条数据
1 | try: |
异常处理
pymysql.err.OperationalError: (1045, “Access denied for user ‘root’@’43.254.54.249’ (using password: YES)”)
- 更换root密码的认证方式为
mysql_native_password
1 | mysql> ALTER USER 'root'@'43.254.54.249' IDENTIFIED WITH mysql_native_password BY 'QAZ!123#'; |
- 授权
1 | mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'43.254.54.249' IDENTIFIED BY 'mypassword' WITH GRANT OPTION; |