SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Aug 2004
    Location
    Scotland
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Create database help

    Hi,

    Hope someone can help, I'm following the "build your own database driven website using php &mysql" book. I'm having probs creating a database as on page 40. This is what I get:

    Code:
    mysql> CREATE DATABASE jokes;
    ERROR 1044: Access denied for user: '@localhost' to database 'jokes'
    Prior to this on page 38 to show databases this is what I got:

    Code:
    mysql> SHOW DATABASES;
    +----------+
    | Database |
    +----------+
    | test     |
    +----------+
    The book shows that I should have had "mysql" before "test". Anyway, I carried on to the next page and deleted the "test" database which I now think was a mistake as it might have contained important info??

    Can anyone help me to get access again to create a database? I'm not able to move forward without this.

    Thanks in advance!

  2. #2
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,708
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you logged in to MySQL as root or a regular user? I don't know if you can see the mysql table as a regular user unless you have been given permission to use it.

  3. #3
    SitePoint Zealot
    Join Date
    Aug 2004
    Location
    Scotland
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, thanks for replying. I was trying to login as root but I never even got to that stage. I think I was doing something silly. I was starting up mysql.exe from C:\mysql\bin instead of using the command prompt. I've tried using command prompt and am now able to create a database.

    However, I'm now having problems with creating a table!

    Code:
    mysql> show databases;
    +----------+
    | Database |
    +----------+
    | jokes    |
    | mysql    |
    +----------+
    2 rows in set (0.00 sec)
    
    mysql> use jokes;
    Database changed
    mysql> CREATE TABLE table_name (
        ->  column_1_name column_1_type column_1_details,
        ->  column_2_name column_2_type column_2_details,
        ->  ...
        -> );
    ERROR 1064: You have an error in your SQL syntax.  Check the manual that corresp
    onds to your MySQL server version for the right syntax to use near 'column_1_typ
    e column_1_details,
     column_2_name column_2_type co
    mysql> CREATE TABLE table_name (
        ->   column_1_name column_1_type column_1_details,
        ->   column_2_name column_2_type column_2_details,
        ->   ...
        -> );
    ERROR 1064: You have an error in your SQL syntax.  Check the manual that corresp
    onds to your MySQL server version for the right syntax to use near 'column_1_typ
    e column_1_details,
      column_2_name column_2_type c
    mysql>
    Any ideas what I'm doing wrong?

    Thanks again

  4. #4
    SitePoint Wizard Lats's Avatar
    Join Date
    Jun 2003
    Location
    Melbourne, AU
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Where you have...
    Code:
    column_1_name column_1_type column_1_details
    you need some detail, something like this...
    Code:
    CREATE TABLE give_me_a_name (
      joke_title varchar(50) NOT NULL default '',
      joke_detail varchar(250) NOT NULL default ''
    )
    Lats...

  5. #5
    SitePoint Zealot
    Join Date
    Aug 2004
    Location
    Scotland
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep. It says that in the book! I guess I should stop working on this so late at night!

    Cheers


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •