How to delete mysql database through shell command

前端 未结 8 1435
遥遥无期
遥遥无期 2020-12-13 05:48

I use the pylons and sqlalchemy. I constantly update the schema files and delete and recreate the database so that new schema can be made.

Every time I do this by o

相关标签:
8条回答
  • 2020-12-13 05:53
    [root@host]# mysqladmin -u root -p drop [DB]
    
    Enter password:******
    
    0 讨论(0)
  • 2020-12-13 05:55

    In general, you can pass any query to mysql from shell with -e option.

    mysql -u username -p -D dbname -e "DROP DATABASE dbname"
    
    0 讨论(0)
  • 2020-12-13 06:05

    MySQL has discontinued drop database command from mysql client shell. Need to use mysqladmin to drop a database.

    0 讨论(0)
  • 2020-12-13 06:07

    Try the following command:

    mysqladmin -h[hostname/localhost] -u[username] -p[password] drop [database]
    
    0 讨论(0)
  • 2020-12-13 06:17

    Another suitable way:

    $ mysql -u you -p
    <enter password>
    
    >>> DROP DATABASE foo;
    
    0 讨论(0)
  • 2020-12-13 06:19

    If you are tired of typing your password, create a (chmod 600) file ~/.my.cnf, and put in it:

    [client]
    user = "you"
    password = "your-password"
    

    For the sake of conversation:

    echo 'DROP DATABASE foo;' | mysql
    
    0 讨论(0)
提交回复
热议问题