mysql 1045 access denied for user 解决方法

提示:1045 access denied for user ‘root‘@‘localhost‘ using password yes
方法一: 
# /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: <输入新设的密码newpassword> 
mysql> 
方法二: 
直接使用/etc/mysql/debian.cnf文件中[client]节提供的用户名和密码: 
# mysql -udebian-sys-maint -p 
Enter password: <输入[client]节的密码> 
mysql> UPDATE user SET Password=PASSWORD(’newpassword’) where USER=’root’; 
mysql> FLUSH PRIVILEGES; 
mysql> quit 
# mysql -uroot -p 
Enter password: <输入新设的密码newpassword> 
mysql>

另一个方法
Windows:

1. 管理员登陆系统,停止mysql服务或者结束mysqld-nt进程
2. 进入命令行,来到mysql的安装目录.假设安装目录为 d:\mysql\ , CMD进入命令行
3. 运行 d:\mysql\bin\mysqld --skip-grant-tables 启动mysql,关闭权限的检查
4. 运行 d:\mysql\bin\mysqladmin -u root flush-privileges password "newpassword" 重设root密码
5. 重新启动mysql服务

第4步也可以直接修改mysql表,所用到的SQL语句同linux部分,这里就不再重复了.

时间: 2024-07-29 07:17:31

mysql 1045 access denied for user 解决方法的相关文章

My-sql #1045 - Access denied for user &#39;root&#39;@&#39;localhost&#39; (using password: NO)

当你重装数据库后出现这个问题的时候,不要着急,首先你要去你的确定你的数据库已经成功的把服务开启了, 然后确定你的密码和账户,IP都确认的情况下, 去寻找config.inc.php 这个文件,根据配置的不同,地方可能出现在不同的地方,如果你配置的是XAMPP的时候, 可能是这个: D:\xampp\phpMyAdmin\config.inc.php 其他路径就没有进行测试了,大不了全盘检索就新行了,然后看里面的 /* Authentication type and info */ $cfg['S

mysql ERROR 1045 (28000): Access denied for user解决方法

问题重现(以下讨论范围仅限Windows环境): C:\AppServ\MySQL> mysql -u root -pEnter password:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 编辑mysql配置文件my.ini(不知道在哪请搜索),在[mysqld]这个条目下加入  skip-grant-tables保存退出后重启mysql 1.点击“开始”->“运行”(

mysql ERROR 1045 (28000): Access denied for user 解决方法 my-default.ini

问题:密码忘记输入错误情况下,登录提示:ERROR 1045 (28000): Access denied for user 查了网上解决方案有个对my.ini文件增加skip-grant-tables这段文字的方案.我的是免安装版的mysql-5.6.24.文件夹下只有my-default.ini文件,如果直接在my-default.ini文件的[mysqld]下添加skip-grant-tables是没有效果的. 可以直接将my-default.ini重命名为my.ini,然后再[mysql

mysql 1045 access denied for user********

另一个方法Windows: 1. 管理员登陆系统,停止mysql服务或者结束mysqld-nt进程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" 重设r

1045 access denied for user &#39;root&#39;@&#39;localhost&#39; using password yes

mysql -u root -p 方法一:  # /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;  mys

Django链接Mysql 8.0 出现错误(1045:Access denied for user &#39;root&#39;@&#39;localhost&#39; (using password: NO) 的一种解决方法

运行环境: Django版本2.0 ; Mysql 版本 8.0.11; 错误代码:  django.db.utils.OperationalError: (1045:Access denied for user 'root'@'localhost' (using password: NO) 这个错误看网上的说法基本都是由于 数据库的 用户名 和 密码 不正确导致的 ,下面是我在Django Setting.py里的设置: ``` DATABASES = { 'default': { 'ENGI

解决MySql 数据库 提示:1045 access denied for user &#39;root&#39;@&#39;localhost&#39; using password yes

今天想用用MySQL 数据库  谁知道老提示 1045 access denied for user 'root'@'localhost' using password yes 最后在csdn 上找到了答案 来源:http://bbs.csdn.NET/topics/310006640     13楼 解决: 1. 开始 --> cmd   --> net stop mysql  (停用MySQL服务  没启动的可以省略) 2. 找到安装路径 MySQL Server 5.1下的my.ini

解决mysql提示错误:1045 access denied for user &#39;root&#39;@&#39;localhost&#39; using password yes

少年,请看下图. 1. 开一个dos 2. 再开一个dos 3.即可.补充一个linux下的: 解决mysql提示错误:1045 access denied for user 'root'@'localhost' using password yes

wamp出现问题#1045 - Access denied for user &#39;root&#39;@&#39;localhost&#39; (using password: NO)的解决方法

打开wamp->apps->phpmyadmin目录下面的config.inc.php文件 cfg['Servers'][$i]['verbose'] = 'localhost';$cfg['Servers'][$i]['host'] = 'localhost';$cfg['Servers'][$i]['port'] = '';$cfg['Servers'][$i]['socket'] = '';$cfg['Servers'][$i]['connect_type'] = 'tcp';$cfg[