云飞凡你好,mysql还用配数据源吗?
我在mysql里没有建立新的用户,使用的还是默认的root,只是改了密码jpwd。
这是怎么回事啊?$conn=mysql_connect("localhost","root","pwd");这样难道不对吗?

解决方案 »

  1.   

    贴代码用户名和密码你都没有指定啊,呵呵(没指定用户名的时候才会用ODBC)
      

  2.   

    不好意思,上面的回复写错了,密码是pwd依然期待大家的回复
      

  3.   

    还没有连接数据库就用了mysql_select_db()函数吧?TestDB_2.php的代码贴出来看看.
    先执行
    $link = mysql_connect('localhost', 'mysql_user', 'mysql_password');另外,这是最基础的问题,还是认真看下PHP手册中 函数参考->MySQL函数库 中各个函数的详细说明及使用方法吧.
      

  4.   

    蓝你好,一下是我的代码:
    <?      $conn=mysql_connect("localhost","root","821007");
            mysql_select_db("test");
            $sql="select   *   from   pet";
            $result=mysql_query($sql);
    ?><form   name="form1"   method="post"   action="">
        <table   width="200"   border="1">
              <tr>
                  <td>Name</td>
                  <td>Owner</td>
                  <td>Species</td>
              </tr>
      <?
      while($arr=mysql_fetch_array($result))
      {
      ?>
              <tr>
                  <td><?echo   "$arr[name]";?></td>
                  <td><?echo   "$arr[owner]";?></td>
                  <td><?echo   "$arr[species]";?></td>
              </tr>
      <?}?>
          </table>
      </form>
      

  5.   

    Access denied for user 'ODBC'@'localhost' (using password: NO)提示你没有输入密码。
      

  6.   

    你能不能把代码原封不动的贴啊
    你的错误提示中TestDB_2.php on line 8 是mysql_select_db
    而你的代码根本就不是
      

  7.   

    Sorry<html>
    <head>
           <title>Title here!</title>
    </head>
    <body>
    <?php      $conn=mysql_connect("localhost","root","821007");
            mysql_select_db("test");
            $sql="select   *   from   pet";
            $result=mysql_query($sql);
    ?><form   name="form1"   method="post"   action="">
        <table   width="200"   border="1">
              <tr>
                  <td>Name</td>
                  <td>Owner</td>
                  <td>Species</td>
              </tr>
      <?php
      while($arr=mysql_fetch_array($result))
      {
      ?>
              <tr>
                  <td><?echo   "$arr[name]";?></td>
                  <td><?echo   "$arr[owner]";?></td>
                  <td><?echo   "$arr[species]";?></td>
              </tr>
      <?php
      }?>
          </table>
      </form>
    </body>
    </html>
      

  8.   

    冒昧的说一句,我感觉这个跟代码没关系,可能是配置的问题吧。
    我新写了一个简单的,还是不行:<!doctype html public "-//W3C//DTD HTML 4.0 //EN"> 
    <html>
    <head>
           <title>Title here!</title>
    </head>
    <body>
    <?php
    $conn = mysql_connect("localhost", "root", "pwd");
    echo $conn;
    mysql_close($conn);
    ?>
    </body>
    </html>结果:Warning: mysql_connect() [function.mysql-connect]: Client does not support authentication protocol requested by server; consider upgrading MySQL client in C:\Program Files\Apache Group\Apache2\htdocs\TestDB.php on line 8Warning: mysql_close(): supplied argument is not a valid MySQL-Link resource in C:\Program Files\Apache Group\Apache2\htdocs\TestDB.php on line 10
      

  9.   

    你把你的连接语句替换成下面这样再执行一遍,把输出的错误信息贴出来看看:
    $link = mysql_connect('localhost', 'root', '821007') or die ('Not connected : ' . mysql_error());
      

  10.   

    Warning: mysql_connect() [function.mysql-connect]: Client does not support authentication protocol requested by server; consider upgrading MySQL client in C:\Program Files\Apache Group\Apache2\htdocs\TestDB_2.php on line 8
    Not connected : Client does not support authentication protocol requested by server; consider upgrading MySQL client我的mysql版本:5.1.20-beta
      

  11.   

    注意: 只要将 server 指定为 "localhost" 或 "localhost:port",MySQL 客户端库会越过此值并尝试连接到本地套接字(Windows 中的名字管道)。如果想用 TCP/IP,应该用 "127.0.0.1" 代替 "localhost"。改成127.0.0.1试试
    $conn = mysql_connect("127.0.0.1", "root", "pwd"); 
      

  12.   


    mysql 新旧版本密码算法不一致导致第一种解决方法:
    mysql> SET PASSWORD FOR
    -> 'some_user'@'some_host' = OLD_PASSWORD('newpwd');比方说数据库用户是admin,主机localhost,密码是123456这时候输入的命令应该是:mysql> SET PASSWORD FOR admin@localhost=OLD_PASSWORD('123456');第二种解决方法:mysql> UPDATE mysql.user SET Password = OLD_PASSWORD('newpwd')
    -> WHERE Host = 'some_host' AND User = 'some_user';
    mysql> FLUSH PRIVILEGES;
    从网上一搜,答案大把大把的
      

  13.   

    不知道你当时是怎样修改root用户密码的,执行下面两条命令再试试(mysql.exe下面执行).SET PASSWORD FOR 'root'@'localhost' = OLD_PASSWORD('821007');
    FLUSH PRIVILEGES;
      

  14.   

    mysql重新安装,估计还是root账号密码设置的时候有点问题。
      

  15.   

    我觉得还是重新安装mysql算了,估计还是root设置的时候是不是有点问题啊。