问题复现
版本信息:
- OS版本:Ubuntu Server 16.04.6 LTS
- TestLink版本:1.9.17
- MySQL版本:8.0.16
- PHP版本:7.0.33
- Apache2版本:2.4.18
TestLink安装过程第四步中Creating Testlink DB user `root`时报错,错误信息如下:
==============================================================================
DB Access Error - debug_print_backtrace() OUTPUT START
ATTENTION: Enabling more debug info will produce path disclosure weakness (CWE-200)
Having this additional Information could be useful for reporting issue to development TEAM.
==============================================================================
排查问题
- 查看日志
vim /var/www/html/testlink/logs/userlog0.log
定位到错误信息:
ERROR ON exec_query() - database.class.php <br />1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘IDENTIFIED BY ‘123456’’ at line 1 - GRANT SELECT, UPDATE, DELETE, INSERT ON `testlink`.* TO ‘root’@‘localhost’ IDENTIFIED BY ‘123456’<br />THE MESSAGE : GRANT SELECT, UPDATE, DELETE, INSERT ON `testlink`.* TO ‘root’@‘localhost’ IDENTIFIED BY ‘123456’
Query failed: errorcode[1064]
errormsg:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘IDENTIFIED BY ‘123456’’ at line 1
- 分析错误原因
mysql 8 版本起已经将创建账户和赋予权限的方式分开了,因此需要将日志中所描述的命令改为:
GRANT SELECT, UPDATE, DELETE, INSERT ON \`testlink\`.* TO 'root'@'localhost';
- 解决方案
找到并修改执行上述命令的脚本:
sudo vim /var/www/html/testlink/install/installUtils.php
将468行注释掉,该行是给sql命令加上“IDENTIFIED BY ‘123456’”,即改为:
//$stmt .= " IDENTIFIED BY '" . $passwd . "'";
然后重新执行安装过程即可。