Search code examples
mysqlubuntulamp

MySQL Syntax Error (Ubuntu LAMP Server)


Alright, so I've got a fairly fresh Ubuntu (server) installation. Just finished installing the LAMP server and when I go to create a database I'm getting the generic syntax error (1064 / 42000).

My query:

CREATE DATABASE phpbb;

Pretty simple and pretty standard, so I'm not sure what the issue is. Any ideas?


Solution

  • It looks from your error like you're trying to execute SQL on the command line, something like:

    mysql -u mike -p CREATE DATABASE phpbb';
    

    MySQL isn't going to like that, it separates the initiation of the tool from the SQL commands.

    What I'd normally do for CREATE DATABASE, as it's a one off, I'd do it manually.

    So start the tool with

    mysql -u mike -p

    This should prompt you for your password, and connect to the local database, giving you a shell prompt:

    mysql>
    

    You then issue your

    CREATE DATABASE phpbb;
    

    If you want to run scripts from the command line, put them in a file and redirect the input to mysql. Usually you'd redirect the output too - something like this:

    mysql -u mike -p < mysqlscript.sql  > outputofscript.log