之前好好的,然后被黑了…

报错3_MySQL被黑后远程连接报错Character set ‘utf-8‘ is not a compiled character set and is not specified_docker

阿里云服务器好像出故障了,估计是把远程连接权限给关了…

报错3_MySQL被黑后远程连接报错Character set ‘utf-8‘ is not a compiled character set and is not specified_docker_02

发现本地远程连接不了

报错3_MySQL被黑后远程连接报错Character set ‘utf-8‘ is not a compiled character set and is not specified_mysql_03


然后进入docker的mysql内部,发现报错

root@96f1910989d5:/usr/share/mysql/charsets# mysql -u root -p
Enter password: 
mysql: Character set 'utf-8' is not a compiled character set and is not specified in the '/usr/share/mysql/charsets/Index.xml' file
mysql: Character set 'utf-8' is not a compiled character set and is not specified in the '/usr/share/mysql/charsets/Index.xml' file
ERROR 2019 (HY000): Can't initialize character set utf-8 (path: /usr/share/mysql/charsets/)

修改my.cnf文件

root@96f1910989d5:/usr/share/mysql/charsets# exit
exit
[root@iZ2vc8owmlobwkazif1efpZ conf]# cd /mydata/mysql/conf/
[root@iZ2vc8owmlobwkazif1efpZ conf]# ls
my.cnf
[root@iZ2vc8owmlobwkazif1efpZ conf]# vim my.cnf
[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqld]
init_connect='SET collation_connection=utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
skip-name-resolve


mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select host,user from user;
+-----------+---------------+
| host      | user          |
+-----------+---------------+
| localhost | mysql.session |
| localhost | mysql.sys     |
| localhost | root          |
+-----------+---------------+
3 rows in set (0.00 sec)

mysql> update user set host ='%' where user ='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> flush privileges; 
Query OK, 0 rows affected (0.00 sec)

mysql>

然后测试本地远程连接,发现解决了

报错3_MySQL被黑后远程连接报错Character set ‘utf-8‘ is not a compiled character set and is not specified_远程连接权限_04