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

来源:互联网 发布:手机域名注册管理局 编辑:程序博客网 时间:2024/05/16 13:37

由于不小心将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连接了。

0 0
原创粉丝点击