- 配置文件PHP.ini修改
打开; extension_dir = "ext",修改成
; extension_dir = "./"
; On windows:
extension_dir = "自己php的存放路径\ext"
2.打开extension=msql.dll
; For example, on Windows:
;
extension=msql.dll
3.修改配置(直接粘贴过去即可)
extension=php_bz2.dll
extension=php_curl.dll
extension=php_fileinfo.dll
extension=php_gd2.dll
extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_intl.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
extension=php_mbstring.dll
extension=php_exif.dll ; Must be after mbstring as it depends on it
extension=php_mysql.dll
extension=php_mysqli.dll
;extension=php_oci8.dll ; Use with Oracle 10gR2 Instant Client
;extension=php_oci8_11g.dll ; Use with Oracle 11gR2 Instant Client
extension=php_openssl.dll
;extension=php_pdo_firebird.dll
extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
extension=php_pdo_odbc.dll
extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
extension=php_pgsql.dll
;extension=php_shmop.dll
; The MIBS data available in the PHP distribution must be installed.
; See http://www.php.net/manual/en/snmp.installation.php
;extension=php_snmp.dll
extension=php_soap.dll
extension=php_sockets.dll
extension=php_sqlite3.dll
;extension=php_sybase_ct.dll
extension=php_tidy.dll
extension=php_xmlrpc.dll
extension=php_xsl.dll
4.修改配置时间
[Date]
; Defines the default timezone used by the date functions
; https://php.net/date.timezone
date.timezone = Asia/Shanghai
2.SQl端配置修改
php5+SQL8报错SERVER SENT CHARSET (255) UNKNOWN和(HY000/2054)的解决方法:
原本运行好好的php,重启了一下后,报错,但是apache24,php5.5,mysql8.0都设置好了,报错内容为:
mysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers
mysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers
这是因为在MySQL 8.0.11中,caching_sha2_password是默认的身份验证插件,而不是以往的mysql_native_password。所以和php不兼容。可以降级php,也可以修改MySQL的配置。
我决定修改MySQL的配置。
可是我进入C:\Program Files\MySQL\MySQL Server 8.0,怎么也找不到配置文件(my.ini或者mysqld.cnf)。
最后在隐藏文件夹ProgramData里找到了,完整路径是C:\ProgramData\MySQL\MySQL Server 8.0\my.ini打开my.ini做如下配置:
[mysqld]
port=3306
character-set-server=utf8
default_authentication_plugin=mysql_native_password
[mysql]
default-character-set=utf8
[client]
default-character-set=utf8
然后在cmd里输入net stop mysql80和net start mysql80
net stop mysql80
net start mysql80
3.mysql_connect:The server requested authentication method unknown to the client [caching_sha2_]
PHP或者 python作为后端语言在连接MySQL的时候,会出现一下的警告提醒:
mysql_connect:The server requested authentication method unknown to the client [caching_sha2_password] in on line55
这是由于 PHP或者Python 的读取密码的形式是mysql_native_password;而当前的MySQL的密码形式是:caching_sha2_password;两者不匹配,导致的错误。
解决办法:
用Navicat对用户进行设置,并保存
进行保存,这个时候重新连接,很可能会出现 密码不正确的提醒
mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES)
如果出现这一步,就在上面的密码项目中重新填写原来的 密码,两次都一样,进行保存。
重新连接,就解决了。
这个方法我已经测试通过了。
不需要使用MySQL编程,只要用到Navicat就好。