Beginning MySQL use w/ PHP: Installed, but unable to create a database.

Discussion in 'macOS' started by dubis07, Jan 22, 2011.

  1. dubis07 macrumors member

    Joined:
    Aug 8, 2007
    #1
    I'm following Head first PHP & MySQL and proceeded through the first chapter on PHP with ease. I hit a snag on the next chapter where it started to utilize MySQL.

    First, I should say that I followed these steps to install/enable Apache, PHP, and MySQL on Snow Leopard.

    When I typed /usr/local/mysql/bin/mysql into Terminal, I get the "Welcome to the MySQL monitor" message that shows the version, copyright info, etc.

    From here, I tried the following:
    mysql> CREATE DATABASE testdatabase;

    but was given the following message:
    ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'testdatabase'

    I'm very new to it all so any help would be greatly appreciated. I also can't seem to find any folders for MySQL just by doing a Finder search, but I have a feeling the files are hidden. Would this be an issue? If I create a database, where would the files be stored?

    Thank you for any help!
     
  2. psxguru macrumors 6502a

    Joined:
    May 19, 2006
    #2
  3. dubis07 thread starter macrumors member

    Joined:
    Aug 8, 2007
    #3
    Although I really do appreciate the recommendation, I'm hoping to follow the book as closely as possible. I feel there is just a simple break in the connection somewhere, but I need some help finding it!

    Any suggestions?
     
  4. Detektiv-Pinky, Jan 22, 2011
    Last edited: Jan 22, 2011

    Detektiv-Pinky macrumors 6502a

    Detektiv-Pinky

    Joined:
    Feb 25, 2006
    Location:
    Berlin, Germany
    #4
    It looks as if you are connecting as an 'anonymous' user to the database. MySQL, as other databases enforces a tight role model, where different users have different permissions. You probably created a database admin during installation. Try connecting with mysql -u root

    Have a look at the MySQL-Documentation, it is very readable and thorough: http://dev.mysql.com/doc/refman/5.1/en/default-privileges.html
     
  5. dubis07 thread starter macrumors member

    Joined:
    Aug 8, 2007
    #5

Share This Page