3 Answers. No, reinstalling mysql-server will not delete you database files, only delete the package files of mysql-server .
To uninstall MySQL on Windows, make sure that your first stop the running server. Once the server is stopped, you can uninstall MySQL via the Windows "Control Panel". Go to "Programs and Features" and select "MySQL" => "Uninstall".
From the MySQL prompt:
mysql> drop database <db_name>;
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?.
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!
drop database <db_name>;
FLUSH PRIVILEGES;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With