How do I remove a MySQL database?

前端 未结 7 2028
傲寒
傲寒 2021-01-29 22:35

You may notice from my last question that a problem caused some more problems, Reading MySQL manuals in MySQL monitor?

My database is now unusable partly due to

相关标签:
7条回答
  • 2021-01-29 22:46
    drop database <db_name>;
    FLUSH PRIVILEGES;
    
    0 讨论(0)
  • 2021-01-29 22:47

    If you are using an SQL script when you are creating your database and have any users created by your script, you need to drop them too. Lastly you need to flush the users; i.e., force MySQL to read the user's privileges again.

    -- DELETE ALL RECIPE
    
    drop schema <database_name>;
    -- Same as `drop database <database_name>`
    
    drop user <a_user_name>;
    -- You may need to add a hostname e.g `drop user bob@localhost`
    
    FLUSH PRIVILEGES;
    

    Good luck!

    0 讨论(0)
  • 2021-01-29 22:52

    If you are working in XAMPP and your query of drop database doesn't work then you can go to the operations tag where you find the column (drop the database(drop)), click that button and your database will be deleted.

    0 讨论(0)
  • 2021-01-29 22:53

    If your database cannot be dropped, even though you have no typos in the statement and do not miss the ; at the end, enclose the database name in between backticks:

    mysql> drop database `my-database`;
    

    Backticks are for databases or columns, apostrophes are for data within these.

    For more information, see this answer to Stack Overflow question When to use single quotes, double quotes, and backticks?.

    0 讨论(0)
  • 2021-01-29 22:54

    For Visual Studio, in the package manager console:

     drop-database
    
    0 讨论(0)
  • 2021-01-29 22:56

    From the MySQL prompt:

    mysql> drop database <db_name>;
    
    0 讨论(0)
提交回复
热议问题