<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }if (mysql_query("CREATE DATABASE my_db",$con))
  {
  echo "Database created";
  }
else
  {
  echo "Error creating database: " . mysql_error();
  }mysql_close($con);
?>
执行后
Warning: mysql_connect(): Access denied for user: 'peter@localhost' (Using password: YES) in E:\php\gggAPMserver\amp\Apache2\htdocs\creatdb.php on line 2
Could not connect: Access denied for user: 'peter@localhost' (Using password: YES)各位大侠,怎么解决?

解决方案 »

  1.   

    密码错误或权限问题,在服务器上执行下面的命令能登录吗:
    mysql -u peter -p
      

  2.   

    仔细看看creatdb.php 第二行,是不是服务器的用户名或者密码那给写错了
      

  3.   

    用户名和密码是MYsql的还是什么的?
      

  4.   

    密码错 基本上是。服务器上 在cmd模式下 到mysql目录 输入 mysql -u xxx -p 回车 u后跟 用户名 回车后要求输入密码 之后看什么反馈吧