Results 1 to 7 of 7
  1. #1
    Join Date
    May 2009
    Posts
    41

    Unanswered: Default escape character in MySQL

    what is the default escape character in MySQL?

    We have in ORACLE like ' " ', in MSSQL like ' [] ' which is used while creating table.

    MSSQL
    create table [aa/njh] (col1 INT);

    ORACLE
    create table "aa/njh" (col1 INT);


    If I use both( ", []) in MYSQL while create table it is not working fine.
    My aim is to have table name with special character on numeric.

    Also
    What is the default schema name in MySQL 5.1.34 like in ORACLE is username (system), in MSSQL is "dbo"?


    I think it is database name Isn't it?

  2. #2
    Join Date
    Aug 2005
    Posts
    30
    " ` " is used as escape character in MySql if you want to use special characters in table name or field name or want to use any reserved word of mysql as table name.

    Create table `aa/njh` (col1 INT);

  3. #3
    Join Date
    May 2009
    Posts
    41
    i got solution as :

    mysql> CREATE TABLE "test" (col INT);
    ERROR 1064: You have an error in your SQL syntax...
    mysql> SET sql_mode='ANSI_QUOTES';
    mysql> CREATE TABLE "test" (col INT);
    Query OK, 0 rows affected (0.00 sec)

  4. #4
    Join Date
    May 2009
    Posts
    41
    We can't use " ' " in create table for table name. used for column name.

    I got the solution as posted below.

  5. #5
    Join Date
    May 2009
    Posts
    41
    mysql> create table 'p1/sdre' (col1 int);
    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 ''p1/s
    dre' (col1 int)' at line 1

    See given solution.

  6. #6
    Join Date
    May 2009
    Posts
    41
    Yes Ashish we can use this also without setting ANSI.

  7. #7
    Join Date
    May 2009
    Posts
    41
    Hi

    I am trying to connect to MySQL database. But it is giving me error as
    "ERROR 1130: Host '' is not allowed to connect to this MySQL server"

    mysql>musql -h 'a.b.c.d' -u root -p
    Enter password: ********

    "ERROR 1130: Host 'a.b.c.d' is not allowed to connect to this MySQL server"

    Also I tried to do the following :

    mysql> create user 'root'@'a.b.c.d' identified by 'root';
    Query OK, 0 rows affected (0.00 sec)

    mysql> grant all privileges on *.* to 'root'@'a.b.c.d' with gran
    t option;
    Query OK, 0 rows affected (0.00 sec)

    mysql> show grants for 'root'@'a.b.c.d';
    +-------------------------------------------------------------------------------
    -----------------------------------------------------------------------+
    | Grants for root@a.b.c.d
    |
    +-------------------------------------------------------------------------------
    -----------------------------------------------------------------------+
    | GRANT ALL PRIVILEGES ON *.* TO 'root'@'a.b.c.d' IDENTIFIED BY
    PASSWORD '*81F5E21E35407D884A6CD4A731AEBFB6AF209E1B' WITH GRANT OPTION |
    +-------------------------------------------------------------------------------
    -----------------------------------------------------------------------+
    1 row in set (0.00 sec)

    >exit

    Again trying from begining

    >mysql -h a.b.c.d -u root –p
    Enter password: ********
    ERROR 1045 (28000): Access denied for user 'root'@'ps4743.persistent.co.in' (usi
    ng password: YES)


    Can you please tell me if anything goes wrong?

Posting Permissions

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