如何恢复/重新创建mysql的默认``mysql''数据库 [英] How to recover/recreate mysql's default 'mysql' database

查看:263
本文介绍了如何恢复/重新创建mysql的默认``mysql''数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我安装mysql时,它带有两个数据库,即mysql和信息模式.我不小心删除了mysql数据库.有什么办法可以重新创建它?

When I installed mysql it came with two database, mysql and information schema. I accidentally deleted the mysql database. Is there any way I can recreate it?

此外,由于它包含一个包含用户信息的表,如果没有它,我是否可以通过任何方式查看用户信息?

Also, since it contains a table that contains user information, would there be any way I can view users' information without it?

推荐答案

如果您仍然可以登录(由于没有用户表,我不能登录)并且要保存数据库,请使用

If you are still able to log in (I assume you aren't since there's no user table) and have databases to save, dump them with

mysqldump --routines databasename > outfile.sql

可以使用以下命令重新创建MySQL数据库

The MySQL database can be recreated with the command

# Most MySQL versions
mysql_install_db

# MySQL 5.7 and later
mysqld --initialize

此处的MySQL文档

这篇关于如何恢复/重新创建mysql的默认``mysql''数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆