您的位置:首页 > 数据库 > SQL

MySql 错误1067,1045( Can't open and lock privilege tables: Table 'mysql.user' doesn't exist)

2017-05-12 14:34 1016 查看
由于不小心将mysql数据库删除了,导致MySql服务无法启动。打开“计算机管理->系统工具->事件查看器->Windows->应用程序”找到MySQL的错误日志:Fatal error: Can’t open and lock privilege tables: Table ‘mysql.user’ doesn’t exist



正对以上问题进行修复,步骤如下:

1.A.如果是.msi文件安装MySQL的,则找到安装MySQL的安装文件,进行数据库的修复;



1.B.如果是压缩包的画,请将原压缩包中的data目录里的mysql文件夹复制到安装的MySql安装目录下的data文件夹下。

2.现在开启MySQL服务成功。cmd执行net start mysql

3.SQLyog连接MySQL数据库时报错1045。那是因为修复MySQL完成后,这时候的密码是默认密码,我也不知道是多少,所有现在就是更改密码。

4.停止MySql服务,然后打开my.ini文件,在[mysqld]下输入skip-grant-tables,保存之后重启MySQL服务

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[mysqld]
skip-grant-tables
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M


5.输入mysql -u root -p之后不用输入密码,出现password:直接回车进入MySQL。

6. 使用数据库:use mysql;

7. 更改密码:update user set password=password(“new_pass”) where user=”root”;

8. 刷新数据库:flush privileges;

9. 最后将在[mysqld]下输入的skip-grant-tables删除。

10. 5-8效果图如下:



11.经过以上步骤就已经大功告成,接着可以用SQLyog连接了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mysql
相关文章推荐