› MySQL 5.5 Community Server
› MySQL 5.6 Community Server
› Percona Configuration Wizard
› XtraBackup 搭建主从复制
Great Sites on MySQL
› Percona
› MySQL Performance Blog
› Severalnines
推荐管理工具
› Sequel Pro
› phpMyAdmin
推荐书目
› MySQL Cookbook
MySQL 相关项目
› MariaDB
› Drizzle
参考文档
› http://mysql-python.sourceforge.net/MySQLdb.html
webjin
V2EX  ›  MySQL

如何删除这个数据库?

  •  
  •   webjin · Mar 8, 2014 · 4246 views
    This topic created in 4587 days ago, the information mentioned may be changed or developed.
    mysql> show master status;
    Empty set (0.00 sec)

    mysql> show databases;
    +--------------------+
    | Database |
    +--------------------+
    | information_schema |
    | #mysql50#.ssh |
    | mysql |
    | test |
    +--------------------+
    4 rows in set (0.00 sec)

    mysql> drop database #mysql50#.ssh ;
    -> ;
    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 '' at line 1
    mysql>
    6 replies  •  1970-01-01 08:00:00 +08:00
    Livid
        1
    Livid  
    MOD
    PRO
       Mar 8, 2014
    用一个 GUI 连上去试试。
    VYSE
        2
    VYSE  
       Mar 8, 2014
    drop database `#mysql50#.ssh` or '#mysql50#.ssh'
    try whatever
    lowstz
        3
    lowstz  
       Mar 8, 2014
    假设 mysql 的 data 目录在 /var/lib/mysql 。
    可以试试暴力删除该数据库的文件夹,不过不太清楚会出现啥不良后果 >.<
    sudo rm -r '/var/lib/mysql/#mysql50#.ssh'

    这种 '#' 字符开头的数据库名也是用 sql 语句死活创建不成功,
    但是在 mysql 的 data 的目录下新建 '#mysql50#.ssh' 这样的文件夹,
    然后用 show databases; 就能看到 '#' 开头的数据库名了,虽然 use 会一直出错。

    Reference:
    http://dev.mysql.com/doc/refman/5.0/en/identifiers.html
    http://stackoverflow.com/questions/4584458/error-dropping-database-cant-rmdir-test-errno-17
    http://superuser.com/questions/705913/delete-a-mysql-database-with-a-strange-name
    Honwhy
        4
    Honwhy  
       Mar 8, 2014
    #号是转义字符么?
    webjin
        5
    webjin  
    OP
       Mar 8, 2014
    解决了,在网上找到了答案~删除/var/lib/mysql 目下的.ssh文件夹。我也不知道文件夹是怎么来的
    可能是这样的来了我写了一个这样的脚本做主从备份。
    #!/usr/bin/env bash
    su mysql
    expect -c "
    spawn scp /root/test [email protected]:/root
    expect {
    \"*assword\" {set timeout 300; send \"123456\r\";}
    \"yes/no\" {send \"yes\r\"; exp_continue;}
    }
    expect eof"
    exit
    ================网上找的正规mysql主从同步我搞了好久都没搞好。
    webjin
        6
    webjin  
    OP
       Mar 8, 2014
    #!/usr/bin/env bash
    su mysql
    expect -c "
    spawn scp /val/lib/mysql/test [email protected]:/val/lib/mysql/test
    expect {
    \"*assword\" {set timeout 300; send \"123456\r\";}
    \"yes/no\" {send \"yes\r\"; exp_continue;}
    }
    expect eof"
    exit
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2902 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 13:36 · PVG 21:36 · LAX 06:36 · JFK 09:36
    ♥ Do have faith in what you're doing.