LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-28-2011, 08:37 AM   #1
ramecare
Member
 
Registered: Feb 2011
Posts: 179

Rep: Reputation: 0
mysql error while creating database


Dear all,

While creating a new database iam facing the below problem,i searched in google to solve but i was not able to solve,can any one help me on this.

mysql> create database auto-download-gta;
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 '-download-gta' at line 1

Thanks,
 
Old 07-28-2011, 08:46 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977
it's becuase you have dashes in the databse name. Ideally, don't use them, but you can quote the name using backticks apparently. Better to change the name.
 
1 members found this post helpful.
Old 07-28-2011, 08:47 AM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 20,404

Rep: Reputation: 4959Reputation: 4959Reputation: 4959Reputation: 4959Reputation: 4959Reputation: 4959Reputation: 4959Reputation: 4959Reputation: 4959Reputation: 4959Reputation: 4959
Quote:
Originally Posted by ramecare View Post
Dear all,
While creating a new database iam facing the below problem,i searched in google to solve but i was not able to solve,can any one help me on this.

mysql> create database auto-download-gta;
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 '-download-gta' at line 1
Must not have looked too hard..putting "linux mysql database name dash" in pulls up 356,000 hits that explain this. The error is very clear, and well-documented. You've got a dash "-" in your database name. Either name your database something else, or put the database name in double-quotes.

If you look any of this up, you'll see LOTS of reasons for not doing this. Mysqldump had (has??) a known issue with databases with dashes in their names. Writing scripts/code for such databases also becomes problematic.
 
Old 07-28-2011, 08:56 AM   #4
ramecare
Member
 
Registered: Feb 2011
Posts: 179

Original Poster
Rep: Reputation: 0
I have given database name with in double-quotes but iam facing the same problem again

mysql> create database "auto-download-gta";
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 '"auto-download-gta"' at line 1


Thanks,
 
Old 07-28-2011, 08:58 AM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 20,404

Rep: Reputation: 4959Reputation: 4959Reputation: 4959Reputation: 4959Reputation: 4959Reputation: 4959Reputation: 4959Reputation: 4959Reputation: 4959Reputation: 4959Reputation: 4959
Quote:
Originally Posted by ramecare View Post
I have given database name with in double-quotes but iam facing the same problem again

mysql> create database "auto-download-gta";
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 '"auto-download-gta"' at line 1
Ok...did you read the posts above? Dashes in a DB is *NOT* a good thing. And I'm not at my machine, so I couldn't test the double-quotes, but acid_kewpie posted about backticks. Did you read that and try it?

Once again...dashes in your DB name is not a good idea and will cause problems.
 
Old 07-28-2011, 08:59 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977
as I already said, use backticks.

For every search result about putting dashes in database names, there is another about someone using quote marks instead of backticks and complaining that it's still not working.
 
Old 07-28-2011, 09:22 AM   #7
ramecare
Member
 
Registered: Feb 2011
Posts: 179

Original Poster
Rep: Reputation: 0
I created the database using backticks,its working Thank u all

mysql> create database `auto-download-gta`;
Query OK, 1 row affected (0.02 sec)


Thanks
 
0 members found this post helpful.
Old 07-28-2011, 09:25 AM   #8
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977
final hint... use a better database name.
 
1 members found this post helpful.
Old 07-28-2011, 11:05 AM   #9
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 20,404

Rep: Reputation: 4959Reputation: 4959Reputation: 4959Reputation: 4959Reputation: 4959Reputation: 4959Reputation: 4959Reputation: 4959Reputation: 4959Reputation: 4959Reputation: 4959
Quote:
Originally Posted by acid_kewpie View Post
final hint... use a better database name.
...and now we're looking forward to the follow-up thread, about how mysqldumps aren't working, and how programs are failing on connect.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mysql database error satish Linux - Server 3 05-11-2010 01:37 AM
creating database in mysql kc3377 Linux - Software 7 05-05-2008 10:18 AM
mysql database error Peter Shepard Ubuntu 1 06-06-2007 11:56 AM
mysql database error Tredo Linux - Security 7 11-26-2004 02:12 PM
creating mysql database Robin01 Linux - Newbie 1 10-28-2003 09:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 02:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration