安装sqli-labs时,mysql 8 报错解决

首先执行命令Setup/reset Database for labs时,mysqlsql时报错:

SETTING UP THE DATABASE SCHEMA AND POPULATING DATA IN TABLES:


Warning: mysql_connect(): Server sent charset (255) unknown to the client. Please, report to the developers in D:\develop\networkSecurity\phpStudy\PHPTutorial\WWW\sqli-labs\sql-connections\setup-db.php on line 29

Warning: mysql_connect(): Server sent charset unknown to the client. Please, report to the developers in D:\develop\networkSecurity\phpStudy\PHPTutorial\WWW\sqli-labs\sql-connections\setup-db.php on line 29
[*]...................Could not connect to DB, check the creds in db-creds.inc: Server sent charset unknown to the client. Please, report to the developers

由错误可知是mysql 8的编码问题。

解决为修改mysql编码为utf8:

1、打卡mysql 8安装目录下的data文件夹,找到my.ini

2、修改两处my.ini中的配置:

        character-set-server= utf8

        default-character-set=utf8

重启mysql,然后再次执行Setup/reset Database for labs,还是报错:

SETTING UP THE DATABASE SCHEMA AND POPULATING DATA IN TABLES:


Warning: mysql_connect(): The server requested authentication method unknown to the client [caching_sha2_password] in D:\develop\networkSecurity\phpStudy\PHPTutorial\WWW\sqli-labs\sql-connections\setup-db.php on line 29

Warning: mysql_query(): MySQL server has gone away in D:\develop\networkSecurity\phpStudy\PHPTutorial\WWW\sqli-labs\sql-connections\setup-db.php on line 42

Warning: mysql_query(): Error reading result set's header in D:\develop\networkSecurity\phpStudy\PHPTutorial\WWW\sqli-labs\sql-connections\setup-db.php on line 42
[*]...................Error purging database: MySQL server has gone away

[*]...................Error creating database: MySQL server has gone away

[*]...................Error creating Table: MySQL server has gone away

[*]...................Error creating Table: MySQL server has gone away

[*]...................Error creating Table: MySQL server has gone away

[*]...................Error creating Table: MySQL server has gone away

[*]...................Error inserting data: MySQL server has gone away

[*]...................Error inserting data: MySQL server has gone away

[*]...................Error purging database: MySQL server has gone away

[*]...................Error creating database: MySQL server has gone away

Unable to connect to the database: challengesMySQL server has gone away

着重看标红的地方,授权有问题。

解决办法还是修改my.ini配置文件:

default_authentication_plugin=mysql_native_password

再次重启mysql8并执行Setup/reset Database for labs,可以看到数据库已经创建成功了:

SETTING UP THE DATABASE SCHEMA AND POPULATING DATA IN TABLES:

[*]...................Old database 'SECURITY' purged if exists

[*]...................Creating New database 'SECURITY' successfully

[*]...................Creating New Table 'USERS' successfully

[*]...................Creating New Table 'EMAILS' successfully

[*]...................Creating New Table 'UAGENTS' successfully

[*]...................Creating New Table 'REFERERS' successfully

[*]...................Inserted data correctly into table 'USERS'

[*]...................Inserted data correctly into table 'EMAILS'

[*]...................Old database purged if exists

[*]...................Creating New database successfully

[*]...................Creating New Table 'XJGY3ZCPBW' successfully

[*]...................Inserted data correctly into table 'XJGY3ZCPBW'

[*]...................Inserted secret key 'secret_FT7Y' into table
 

你可能感兴趣的:(mysql,数据库)