0

I am trying to create a user with the following command. I am getting the below error.

CREATE DATABASE wp-test;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-isdi' at line 1.

I am trying to install wordpress, and after following all the steps I am getting below error.

This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at localhost. This could mean your host’s database server is down.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Suraj
  • 2,423
  • 12
  • 39
  • 75

2 Answers2

2

It's the best practice to use underscore instead of hyphens in database and table names because hyphens are not valid identifier in this condition you need to use backticks around the database name.

Example:

CREATE DATABASE `wp-test`;
devpro
  • 16,184
  • 3
  • 27
  • 38
  • Solved it, thanks but now while creating a user I am getting this `ERROR 1396 (HY000): Operation CREATE USER failed for 'suraj'@'localhost' ` This is how I am trying `CREATE USER suraj@localhost IDENTIFIED BY 'password';` – Suraj Feb 11 '16 at 06:57
  • @Suraj: for ERROR 1396, check this question, there are so many solution here.. http://stackoverflow.com/questions/5555328/error-1396-hy000-operation-create-user-failed-for-jacklocalhost – devpro Feb 11 '16 at 06:59
  • @Suraj: one case study regarding CREATE USE: http://bugs.mysql.com/bug.php?id=28331 – devpro Feb 11 '16 at 07:00
  • I get this whole creating the user. `ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE USER suraj@localhost IDENTIFIED BY 'password'' at line 2 ` – Suraj Feb 11 '16 at 07:07
1

try this sql command to create user

CREATE USER 'suraj'@'localhost';GRANT USAGE ON *.* TO 'suraj'@'localhost' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;

and give user all the privileges..

  • I get this error now. `ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE USER suraj@localhost IDENTIFIED BY 'password'' at line 2 ` – Suraj Feb 11 '16 at 07:07
  • @Suraj: did u check manual? https://dev.mysql.com/doc/refman/5.5/en/create-user.html – devpro Feb 11 '16 at 07:12
  • okk try this.....CREATE USER 'suraj'@'localhost' IDENTIFIED BY 'new_password' PASSWORD EXPIRE; – Pruthviraj Chudasama Feb 11 '16 at 07:13
  • or you can check reference from http://dev.mysql.com/doc/refman/5.7/en/create-user.html – Pruthviraj Chudasama Feb 11 '16 at 07:14