0

I am logged into mysql with terminal on mac Lion, but I get an error running php testscript

these where my steps:

virtualhost is "test.dev"

after Homebrew install logged in with:

mysql -u root

created database

CREATE DATABASE `lara` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

output php testscript

<?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)

now setting a password

mysqladmin -u root password xxx

I have restarted mysql and also granted "root" al priviliges

I still cannot connect

Where do I look to fix this?

Richard
  • 4,516
  • 11
  • 60
  • 87

2 Answers2

1

Try this:

Log in as root, then run the following MySQL commands:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost';
FLUSH PRIVILEGES;

Original answer.

Community
  • 1
  • 1
Luigi Siri
  • 2,068
  • 2
  • 19
  • 27
0

> mysql -u root -p

after I hit "Enter" when it asks for the password it was obvious

I thought I set a password, but that did not stick

so I try'd it another way

use mysql;
UPDATE user set Password=PASSWORD("NEW_PASSWORD_HERE") where User='root';
flush privileges;
quit

that, finally worked

( be carefull about the syntax, on some other posts the uppercasings where missing)

Richard
  • 4,516
  • 11
  • 60
  • 87