在这里,我们将给大家分享关于解决mysql登录报错ERROR1045(28000):Accessdeniedforuser''root''@''localhost''(usingp...的知识,同时也
在这里,我们将给大家分享关于解决 mysql 登录报错 ERROR 1045 (28000): Access denied for user ''root''@''localhost'' (using p...的知识,同时也会涉及到如何更有效地006 - 解决 ERROR 1045 (28000): Access denied for user ''root''@''localhost'' (using passwo...、Centos7解决MySQL登录ERROR 1045 (28000): Access denied for user ‘‘@‘localhost‘ (using passwor)问题、ERROR 1045 (28000): Access denied for user ''mysql''@''localhost'' (using password: YES、ERROR 1045 (28000): Access denied for user ''root''@''localhost'' (using password: NO)的内容。
本文目录一览:- 解决 mysql 登录报错 ERROR 1045 (28000): Access denied for user ''root''@''localhost'' (using p...
- 006 - 解决 ERROR 1045 (28000): Access denied for user ''root''@''localhost'' (using passwo...
- Centos7解决MySQL登录ERROR 1045 (28000): Access denied for user ‘‘@‘localhost‘ (using passwor)问题
- ERROR 1045 (28000): Access denied for user ''mysql''@''localhost'' (using password: YES
- ERROR 1045 (28000): Access denied for user ''root''@''localhost'' (using password: NO)
解决 mysql 登录报错 ERROR 1045 (28000): Access denied for user ''root''@''localhost'' (using p...
问题描述:
在 ubuntu14.04 上安装完 MYSQL 后,MYSQL 默认给分配了一个默认密码,但当自己在终端上使用默认密码登录的时候,总会提示一个授权失败的错误。
报错信息:Access denied for user ''root''@''localhost'' (using password: YES)
执行过程:
sue@suepc:/usr/local/mysql$ mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user ''root''@''localhost'' (using password: YES)
解决方案:
重置 root 密码。
步骤如下:
1. 把 mysql 停止。
$ sudo /etc/init.d/mysql stop
[ ok ] Stopping mysql (via systemctl): mysql.service.
2. 启动 mysqld_safe。
$ sudo mysqld_safe --skip-grant-tables &
[1] 28860
(如果遇到错误
sue@suepc:~$ sudo mysqld_safe --skip-grant-tables &
[1] 7002
sue@suepc:~$ 2018-04-19T07:16:59.386922Z mysqld_safe Logging to ''/var/log/mysql/error.log''.
2018-04-19T07:16:59.475648Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 或 mysqld_safe Directory ''/var/run/mysqld'' for UNIX socket file don''t exists.
则执行下面命令后再次启动 mysqld_safe。
(sudo mkdir -p /var/run/mysqld
sudo chown mysql:mysql /var/run/mysqld
)
3. 进入 mysql,执行两条命令:
$ mysql -u root
mysql> UPDATE mysql.user SET authentication_string = PASSWORD(''123456'') , password_expired = ''N'' WHERE User = ''root'' AND Host = ''localhost'';
Query OK, 0 rows affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 1
mysql> update mysql.user set plugin="mysql_native_password";
Query OK, 1 row affected (0.00 sec)
Rows matched: 3 Changed: 1 Warnings: 0
注意 Mysql 5.7 版本要修改的字段为 authentication_string,而不是 Password。另外,plugin 字段的值要置成 "mysql_native_password"。
4. 退出 mysql
5. 停止 Mysql
$ sudo /etc/init.d/mysql stop
[ ok ] Stopping mysql (via systemctl): mysql.service.
$ sudo kill -9 $(pgrep mysql)
6. 再次启动 mysql
$ sudo /etc/init.d/mysql start
[ ok ] Starting mysql (via systemctl): mysql.service.
再次用密码可以登录。登陆后退出 mysql.
$ mysql -uroot -p
Enter password:
mysql> quit
Bye
006 - 解决 ERROR 1045 (28000): Access denied for user ''root''@''localhost'' (using passwo...
本文转载自:https://blog.csdn.net/hua1011161696/article/details/80666025
解决方案:
步骤一:关闭数据库服务端 mysqld 程序
两种方式:
①快捷键 windows + R ;输入 services.msc ; 找到 MySQL 停止其服务(前提是你之前已经把 MySQL 加入了系统服务中)
②在命令行程序中;注意需要以管理员权限运行 cmd 程序,不然无法关闭 mysqld 进程
>>tasklist |findstr mysqld 这行命令可以用来查看 mysqld 是否在运行,在运行中则可以查到它的 PID
>>taskkill /F/PID xxxx xxxx 是从前面一条命令得到的 PID 值
步骤二:跳过权限登录 MySQL 服务器端
在 cmd 中执行 mysqld --skip-grant-tables
>>mysqld --skip-grant-tables
此时 cmd 程序会阻塞,关闭 cmd 程序 然后重新以管理员权限运行 cmd
然后在 cmd 命令行中输入 mysql 就能连接上 MySQL 服务器端了
>>mysql
然后可以通过 sql 语句 :SELECT * from mysql.user\G; 来查看服务器端所有的用户信息,重点查看 User、Password、authentication_string 这三项。这条语句非常关键。
步骤三:修改密码
依次执行如下 sql 语句:
update mysql.user set authentication_string=password(''321'') where user = ''root'';
flush privileges;
上面第一条 sql 语句中 password ('' 密码 '') 函数中写你想要改成的密码,我这用的是密码 321
接着执行:
SELECT * from mysql.user\G;
去找到 root 用户的 authentication_string 这项,并把它的值记下来。
MySQL 会给密码进行加密,你想要设置的密码进行加密后的值就等于此时 authentication_string 这项的值
所以接下来把 Password 这项的值也设置成此时 authentication_string 项的值就 ok 了;我设置的密码是 321 ,其对应的密文是 *7297C3E22DEB91303FC493303A8158AD4231F486
执行下面两条 sql 语句:
update mysql.user set password = ''*7297C3E22DEB91303FC493303A8158AD4231F486'' where user = ''root'';
flush privileges;
步骤四:
输入 quit 退出 mysql ;然后就可以直接登录了
>>mysql -u root -p
--------------------------------------------------------------------------------
当然也可以重启下 mysqld 再登录
再次提醒:需要以管理员权限运行 cmd
>>tasklist |findstr mysqld
>>taskkill /F /PID xxxx
然后就是启动 mysqld 程序
(不知怎么把 mysqld 加入系统服务中去可看点击打开链接)
>>mysqld
若已经把 mysqld 程序加入了系统服务中,则需要在系统服务中启动 MySQL 服务端
快捷键 windows + R ;输入 services.msc ;
最后就是重新登录
>>mysql -u root -p
在 Password:处填入你前面设置的密码
补充:修改密码时报语法错误解决方法
问题:
mysql> update mysql.user set authentication_string=password(''321'') where user = ''root'';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''(''321'') where user = ''root'''' at line 1
解决方法:
使用如下语句即可解决
alter user ''root''@''localhost'' identified by ''123'';
Centos7解决MySQL登录ERROR 1045 (28000): Access denied for user ‘‘@‘localhost‘ (using passwor)问题
登录数据库时,发现数据库连接不上,报错如下:
ERROR 1045 (28000): Access denied for user ''root''@''localhost'' (using passwor:yes)
为了以后方便排查,这里记录一下。
首先,停止MySQL服务
systemctl stop
mysqld.service
既然是密码错误,那么就先跳过密码验证的步骤
vim /etc/my.cnf
然后,搜索mysqld,找到[mysqld](port=3306上面那个):
/mysqld(在vim编辑状态下直接输入该命令可搜索文本内容)。
注:windows下修改的是my.ini。
在 [mysqld] 底下添加语句:
skip-grant-tables
(注:skip-grant-tables:不启动grant-tables授权表,作为启动参数的作用:MYSQL服务器不加载权限判断,任何用户都能访问数据库)
这是用来跳过密码验证的,添加之后保存退出。
重新启动MySQL服务
systemctl restart mysqld.service
进入MySQL
mysql -u root -p
出现密码输入时,不用输入直接按回车,就可以不用密码就能登录修改密码
使用mysql数据库
use mysql;
mysql> update user set password=password("newpassword") where user="root";
如果报错:
ERROR 1054(42S22) Unknown column ''password'' in ''field list''
原因: 5.7版本下的mysql数据库下已经没有password这个字段了,password字段改成了authentication_string
-
mysql> update user set authentication_string=password("newpassword") where user="root";
-
#刷新MySQL权限相关的表
-
mysql> flush privileges;
-
mysql> exit;
密码修改完毕
vim /etc/my.cnf
编辑my.cnf(Windows下my.ini),将上面添加的内容去掉(skip-grant-tables)。
重启MySQL
systemctl restart mysqld.service
使用新密码登录即可
Buy me a cup of coffee :)
ERROR 1045 (28000): Access denied for user ''mysql''@''localhost'' (using password: YES
解决方法:
利用 mysql 安装时的默认用户名登录 mysql 后, 输入以下命令修改 root 密码
mysql> ALTER USER ''root''@''localhost'' IDENTIFIED BY ''MyNewPass'';
2. 授予用户权限
GRANT ALL PRIVILEGES ON *.* TO ''jiang''@''%'' IDENTIFIED BY ''1'';
flush privileges;
下面的内容没有用到
一。有时可以直接输入命令: mysql 进入数据库
启动数据库:# mysqld_safe &
二。查看用户命令:
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select host,user from mysql.user;//show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql>
删除用户
mysql>Delete FROM user Where User=''test'' and Host=''localhost'';
mysql>flush privileges;
mysql>drop database testDB; //删除用户的数据库
删除账户及权限:>drop user 用户名@''%'';
>drop user 用户名@ localhost;
创建用户
mysql> create user ''root''@''%'' identified by ''1'';# %代表所有端口
Query OK, 0 rows affected (0.07 sec)
mysql> select host,user from mysql.user;
+-----------+------------------+
| host | user |
+-----------+------------------+
| % | root |
| % | usrabc |
| localhost | mysql.infoschema |
| localhost | mysql.session |
| localhost | mysql.sys |
+-----------+------------------+
5 rows in set (0.00 sec)
查看数据库列表:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
+--------------------+
1 row in set (0.00 sec)
mysql>
ERROR 1045 (28000): Access denied for user ''root''@''localhost'' (using password: NO)
首次使用phpnow中的MySQL,phpMyAdmin能打开,但是在cmd中不能打开,出现以下错误:
谢谢回答!
回复内容:
首次使用phpnow中的MySQL,phpMyAdmin能打开,但是在cmd中不能打开,出现以下错误:
谢谢回答!
mysql -u 用户名 -p
今天的关于解决 mysql 登录报错 ERROR 1045 (28000): Access denied for user ''root''@''localhost'' (using p...的分享已经结束,谢谢您的关注,如果想了解更多关于006 - 解决 ERROR 1045 (28000): Access denied for user ''root''@''localhost'' (using passwo...、Centos7解决MySQL登录ERROR 1045 (28000): Access denied for user ‘‘@‘localhost‘ (using passwor)问题、ERROR 1045 (28000): Access denied for user ''mysql''@''localhost'' (using password: YES、ERROR 1045 (28000): Access denied for user ''root''@''localhost'' (using password: NO)的相关知识,请在本站进行查询。
本文标签: