MySQL 设置root密码报错:mysqladmin: connect to server at 'localhost' failed

MySQL 设置root密码报错:mysqladmin: connect to server at ‘localhost‘ failed

1.安装完MySQL设置root密码报错如下

[root@vm172-31-0-6 data]# mysqladmin -uroot password "linux@123"
mysqladmin: connect to server at ‘localhost‘ failed
error: ‘Access denied for user ‘root‘@‘localhost‘ (using password: NO)‘

2.停止MySQL服务

[root@vm172-31-0-6 ~]# systemctl stop mysqld.service

3 安全模式启动

[root@vm172-31-0-6 mysql]# mysqld_safe --skip-grant-tables &
[1] 20777
[root@vm172-31-0-6 mysql]# 190315 01:43:28 mysqld_safe Logging to ‘/var/log/mysqld.log‘.
190315 01:43:28 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

4 无密码root帐号登陆

[root@vm172-31-0-6 mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.43-log MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

mysql> use mysql;
Database changed

5 手动update修改密码

mysql> update user set password=password("linux@123") where user=‘root‘ and host=‘localhost‘;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye

重新使用密码登录

[root@vm172-31-0-6 mysql]# mysql -uroot -plinux@123
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.43-log MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

mysql>

6 正常重新启动

[root@vm172-31-0-6 ~]# service mysqld start

#查看进程

[root@vm172-31-0-6 ~]# ps -ef|grep mysql
root     19768 17076  0 01:37 pts/1    00:00:00 tail -f -n 300 /var/log/mysqld.log
mysql    27591     1  0 02:01 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
mysql    27820 27591  8 02:01 ?        00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
root     27849 27405  0 02:01 pts/2    00:00:00 grep --color=auto mysql

#查看端口号

[root@vm172-31-0-6 ~]# netstat -lntup|grep 3306
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      27820/mysqld        

至此mysql密码修改完成。

MySQL 设置root密码报错:mysqladmin: connect to server at 'localhost' failed

原文地址:https://www.cnblogs.com/heyongboke/p/10534655.html

时间: 2024-11-05 17:44:15

MySQL 设置root密码报错:mysqladmin: connect to server at 'localhost' failed的相关文章

MySQL root密码重置 报错:mysqladmin: connect to server at 'localhost' failed的解决方案

===========================================================二,忘记本地root的登录密码解决过程:1.编辑/mysql/my.ini在[mysqld] 配置部分添加一行skip-grant-tables 2.保存后重启mysql[[email protected] etc]# service mysqld restartShutting down MySQL.                                      

MYSQL登录错误:mysqladmin: connect to server at ‘localhost’ failed

一.mysql登录错误 mysqladmin: connect to server at 'localhost' failed       error: 'Access denied for user 'root'@'localhost' (using password: YES)' 解决办法:破解mysql密码 #> service mysqld stop       #>mysqld_safe --skip-grant-tables &       输入 mysql -uroot

mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: YES)'

就当作自己忘记Mysql密码把,忘记密码的解决方法 一.mysql登录错误mysqladmin: connect to server at 'localhost' failederror: 'Access denied for user 'root'@'localhost' (using password: YES)'无法修改密码用 service mysqld stopmysqld_safe --skip-grant-tables &输入 mysql -uroot -p 回车进入>use

MYSQL登录错误:mysqladmin: connect to server at 'localhost' failed

一.mysql登录错误mysqladmin: connect to server at 'localhost' failederror: 'Access denied for user 'root'@'localhost' (using password: YES)'无法修改密码用 service mysqld stopmysqld_safe --skip-grant-tables &输入 mysql -uroot -p 回车进入>use mysql;> update user set

mysqladmin: connect to server at 'localhost' failed

1:mysqladmin: connect to server at 'localhost' failed 2: 3: 4: mysqladmin: connect to server at 'localhost' failed

mysql5.7设置简单密码报错ERROR 1819 (HY000): Your password

[问题] 有时候,只是为了自己测试,不想密码设置得那么复杂,譬如只想设置root的密码为123456. SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456'); 但是会报错: mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123');ERROR 1819 (HY000): Your password does not satisfy the current policy re

mysql 5.7密码报错 ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

1.重新修改密码,语句如下: mysql> alter user 'root'@'localhost' identified by '123'; Query OK, 0 rows affected (0.00 sec) 2.如果修改过程出现错误(如下),转后面操作: mysql> alter user 'root'@'localhost' identified by '123'; ERROR 1819 (HY000): Your password does not satisfy the cu

Linux 上安装 Mysql 设置root密码问题

Ubuntu 18.10.1 Mysql 5.7.26-0 1. 安装mysql apt-get install mysql-server 安装完可以直接使用,但是新版本在安装过程中没有提示设置root用户密码,使用如下方法设置: sudo mysql_secure_installation 过程中提示是否开启 VALIDATE PASSWORD PLUGIN,就是设置密码强度检查,自行选择: VALIDATE PASSWORD PLUGIN can be used to test passwo

MySQL设置外键报错 #1452 - Cannot add or update a child row: a foreign key constraint fails 解决方法

MySQL数据库,当我尝试在A表中设置B表的主键为外键时,报出错误:#1452 - Cannot add or update a child row: a foreign key constraint fails  于是去搜索了一下 "#1452 - Cannot add or update a child row: a foreign key constraint fails" 的含义与解决方法,根据这篇博文去排查了报错原因,排除了可能1和可能2,然后去研究可能3的具体含义,一开始并