Home > Database > Mysql Tutorial > [mysql]重装windows后恢复mysql及"Accessdeniedfor_MySQL

[mysql]重装windows后恢复mysql及"Accessdeniedfor_MySQL

WBOY
Release: 2016-06-01 13:06:57
Original
896 people have browsed it

mysql数据库实际上是绿色软件,重装系统后还是可以继续使用的。

1、重装系统后保留原先的mysql安装目录和数据目录。

2、制作一个批处理文件用于启动mysql:【run.bat】该文件存放在mysql安装目录下的bin下。

mysqld.exe --defaults-file=../my-default.ini --console

3、执行run.bat即可。

如果连接数据库时出现以下错误:"Access denied for user'root'@'IP'"

1. 管理员登陆系统,停止mysql服务或者结束mysqld进程
2. 进入命令行,来到mysql的安装目录.假设安装目录为 d:/mysql/ , CMD进入命令行
3. 运行 d:/mysql/bin/mysqld-nt --skip-grant-tables 启动mysql,关闭权限的检查

4. 运行 d:/mysql/bin/mysqladmin -u root flush-privileges password 搜索"newpassword" 重设root密码
5. 重新启动mysql服务

Linux系统下可以采用以下方式:

方法一:
# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD(’newpassword’) where USER=’root’;
mysql> FLUSH PRIVILEGES;
mysql> quit
# /etc/init.d/mysql restart
# mysql -uroot -p
Enter password:
mysql>
方法二:
直接使用/etc/mysql/debian.cnf文件中[client]节提供的用户名和密码:
# mysql -udebian-sys-maint -p
Enter password:
mysql> UPDATE user SET Password=PASSWORD(’newpassword’) where USER=’root’;
mysql> FLUSH PRIVILEGES;
mysql> quit
# mysql -uroot -p
Enter password:
mysql>


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template