我在 mac Lion 上使用终端登录 mysql,但运行 php testscript 时出错
这些我的步骤:
虚拟主机是“test.dev”
在 Homebrew install 登录后:
mysql -u root
创建的数据库
CREATE DATABASE `lara` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
输出php测试脚本
<?php
$num_entries = 20;
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "redres"; (at first was set to root)
$dbname = "lara";
$con = mysql_connect($dbhost, $dbuser, $dbpass);
if (!$con) die('Could not connect: ' . mysql_error());
mysql_select_db($dbname, $con);
Warning: mysql_connect(): Access denied for user 'root'@'localhost' (using password: YES) in /Users/redres/Webdev/testsite/index.php on line 19
Could not connect: Access denied for user 'root'@'localhost' (using password: YES)
现在设置密码
mysqladmin -u root password xxx
我已经重新启动了 mysql 并且还授予了“root”权限
我仍然无法连接
我在哪里寻找解决这个问题?