MySQL报错解决方法
-
-
- 1)Warning: (3719, u"'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.")
- 2)pymysql.err.InternalError: (1130, u"Host '10.0.0.5' is not allowed to connect to this MySQL server")
- 3) ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
- 4) ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:yes)
- 5) ERROR 1142 (42000): SELETE command denied to user 'root'@'localhost' for table 'user'
-
1)Warning: (3719, u"‘utf8’ is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.")
报错如下:
解决方法: python 2.7+mysql:8.0
- 查看mysql字符集:
mysql> SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';
- 根据上述查询结果,修改sql语句;
修改前 = ‘CREATE DATABASE IF NOT EXISTS database_name DEFAULT CHARSET utf8 COLLATE utf8_general_ci;’
修改后 = ‘CREATE DATABASE IF NOT EXISTS database_name DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;’
2)pymysql.err.InternalError: (1130, u"Host ‘10.0.0.5’ is not allowed to connect to this MySQL server")
报错原因: 不容许本地机器连远程mysql服务;
解决步骤:
- 本机连接MySQL数据库:
# mysql -uroot -p123456
- 操作mysql数据库
mysql>use mysql; mysql>select 'host' from user where user='root'; mysql>update user set host='%' where user='root'; mysql>flush privileges;
3) ERROR 1062 (23000): Duplicate entry ‘%-root’ for key ‘PRIMARY’
报错场景: 开启MySQL远程操作时,会报1062错误
[root@-linux ~]# mysql -uroot -p123456
mysql> update mysql.user set ho