<?php
// 连接,选择数据库
$link = mysql_connect('localhost', 'root', 'fire0531')
or die('Could not connect: ' . mysql_error());
echo 'Connected successfully';
mysql_select_db('mysql') or die('Could not select database');
// 关闭连接
mysql_close($link);
?>
运行时出错提示如下:
Warning: mysql_connect() [function.mysql-connect]: Client does not support authentication protocol requested by server; consider upgrading MySQL client in c:\Apache\Apache\htdocs\link.php on line 3
Could not connect: Client does not support authentication protocol requested by server; consider upgrading MySQL client我的phpinfo()如下
mysql
MySQL Support enabled
Active Persistent Links 0
Active Links 0
Client API version 3.23.57 Directive Local Value Master Value
mysql.allow_persistent On On
mysql.connect_timeout 60 60
mysql.default_host no value no value
mysql.default_password no value no value
mysql.default_port no value no value
mysql.default_socket no value no value
mysql.default_user no value no value
mysql.max_links Unlimited Unlimited
mysql.max_persistent Unlimited Unlimited
mysql.trace_mode Off Off
odbc
ODBC Support enabled
Active Persistent Links 0
Active Links 0
ODBC library Win32 Directive Local Value Master Value
odbc.allow_persistent On On
odbc.check_persistent On On
odbc.default_db no value no value
odbc.default_pw no value no value
odbc.default_user no value no value
odbc.defaultbinmode return as is return as is
odbc.defaultlrl return up to 4096 bytes return up to 4096 bytes
odbc.max_links Unlimited Unlimited
odbc.max_persistent Unlimited Unlimited
// 连接,选择数据库
$link = mysql_connect('localhost', 'root', 'fire0531')
or die('Could not connect: ' . mysql_error());
echo 'Connected successfully';
mysql_select_db('mysql') or die('Could not select database');
// 关闭连接
mysql_close($link);
?>
运行时出错提示如下:
Warning: mysql_connect() [function.mysql-connect]: Client does not support authentication protocol requested by server; consider upgrading MySQL client in c:\Apache\Apache\htdocs\link.php on line 3
Could not connect: Client does not support authentication protocol requested by server; consider upgrading MySQL client我的phpinfo()如下
mysql
MySQL Support enabled
Active Persistent Links 0
Active Links 0
Client API version 3.23.57 Directive Local Value Master Value
mysql.allow_persistent On On
mysql.connect_timeout 60 60
mysql.default_host no value no value
mysql.default_password no value no value
mysql.default_port no value no value
mysql.default_socket no value no value
mysql.default_user no value no value
mysql.max_links Unlimited Unlimited
mysql.max_persistent Unlimited Unlimited
mysql.trace_mode Off Off
odbc
ODBC Support enabled
Active Persistent Links 0
Active Links 0
ODBC library Win32 Directive Local Value Master Value
odbc.allow_persistent On On
odbc.check_persistent On On
odbc.default_db no value no value
odbc.default_pw no value no value
odbc.default_user no value no value
odbc.defaultbinmode return as is return as is
odbc.defaultlrl return up to 4096 bytes return up to 4096 bytes
odbc.max_links Unlimited Unlimited
odbc.max_persistent Unlimited Unlimited
4.0之前的认证方法不一样。
或者 另建一个与 mysql 4.0 兼容的账号。以root 登录后mysql> CREATE USER 'afireisagao'@'localhost';
Query OK, 0 rows affected (0.39 sec)mysql> SET PASSWORD FOR 'afireisagao'@'localhost' = OLD_PASSWORD('fire0531');
Query OK, 0 rows affected (0.06 sec)mysql>然后改你的连接为
$link = mysql_connect('localhost', 'afireisagao', 'fire0531')