V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
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 · 2014-03-08 02:27:52 +08:00 · 3193 次点击
    这是一个创建于 3704 天前的主题,其中的信息可能已经有所发展或是发生改变。
    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 条回复    1970-01-01 08:00:00 +08:00
    Livid
        1
    Livid  
    MOD
       2014-03-08 02:32:23 +08:00
    用一个 GUI 连上去试试。
    VYSE
        2
    VYSE  
       2014-03-08 03:03:42 +08:00
    drop database `#mysql50#.ssh` or '#mysql50#.ssh'
    try whatever
    lowstz
        3
    lowstz  
       2014-03-08 07:20:30 +08:00
    假设 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  
       2014-03-08 10:42:53 +08:00
    #号是转义字符么?
    webjin
        5
    webjin  
    OP
       2014-03-08 14:11:57 +08:00
    解决了,在网上找到了答案~删除/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
       2014-03-08 14:12:55 +08:00
    #!/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
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1158 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 18:18 · PVG 02:18 · LAX 11:18 · JFK 14:18
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.