文档章节

MYSQL登录错误:mysqladmin: connect to server

SODEVE
 SODEVE
发布于 2016/06/06 22:59
字数 709
阅读 130
收藏 0

最近安装mysql后,由于默认密码为空,也登陆不了,通过 mysqladmin –u root password  无法设置密码,一直提示如下错误

[root@maizi ~]# mysqladmin -u root password 'root'
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'

解决办法如下:

--skip-grant-tables:不启动grant-tables(授权表),跳过权限控制的作用

[root@maizi ~]# service mysqld stop
停止 mysqld:                                              [确定]
[root@maizi ~]# mysqld_safe --skip-grant-tables &
[2] 3207
[root@maizi ~]# 2016-06-06T14:17:46.748722Z mysqld_safe Logging to '/var/log/mysqld.log'.
2016-06-06T14:17:46.801232Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
 mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.13 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, 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> 

还有一直方式就是在my.cnf配置文件中添加  skip-grant-tables

[root@maizi ~]# cat /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]
#
# 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
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
#skip-grant-tables
[root@maizi ~]# 

成功登录mysql后就可以修改密码了,操作如下:

mysql> use mysql;
Database changed
mysql> update user set authentication_string=PASSWORD('123456') where user='root' and host='localhost';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1

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

mysql> quit;
Bye
[root@maizi ~]# mysql -uroot -p123456;
mysql: [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 5
Server version: 5.7.13

Copyright (c) 2000, 2016, 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> 

修改密码后确实可以登录了,当是登录基本上啥做不了,还需要重新设置一下密码

mysql> show database;
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 'database' at line 1
mysql> SET PASSWORD = PASSWORD('123456');
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> SET PASSWORD = PASSWORD('maizi_123456');
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> SET PASSWORD = PASSWORD('MAIzi_123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> 

ps:视乎我这个版本( 5.7.13 )的密码限定了密码规则,导致纯数字、纯字母都设置不成功,我估摸着至少必须包含字母大小写加数字吧。

© 著作权归作者所有

SODEVE
粉丝 2
博文 28
码字总数 10177
作品 0
深圳
程序员
私信 提问
加载中

评论(1)

tomener
tomener
对的,就这么做的
MYSQL登录错误:mysqladmin: connect to server at 'localh

MYSQL登录错误:mysqladmin: connect to server at 'localhost' failed 2013年11月04日 19:58:04 阅读数:20082 一、mysql登录错误 mysqladmin: connect to server at 'localhost' failed er......

xiaocao13140
2018/05/24
0
0
mysql flush-hosts

错误信息: message from server: "Host 'ip' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'" 1、使用mysqladmin flush-hosts命令清除缓存,命令执......

xuanxiangyu
2017/02/17
0
0
ERROR 1045 (28000): Access denied for user 'root'@

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor 错误描述: Mysql中添加用户之后可能出现登录时提示ERROR 1045 (28000): Access denied for user的错误.删除......

xiaocao13140
2018/07/02
0
0
MySQL 问题解决

问题如下: Failed to Connect to MySQL at 127.0.0.1:3306 with user root Access denied for user 'root'@'localhost' 我的问题是terminal中可以使用管理员账号登录mysql,但是在使用workb......

东风冷雪
2017/12/05
0
0
mysql rpm安装后的密码修改

由于在fedora下用 mysql官方源安装myslq后,root用户密码为随机生成,没找到默认密码文件在哪里,导致找不到方法进入数据库。 以下是解决过程,记录下来以备后患: 解决mysql“Access denied...

Korey
2014/04/20
355
0

没有更多内容

加载失败,请刷新页面

加载更多

Spring Cloud Sleuth 整合 feign 源码分析

org.springframework.cloud.sleuth.instrument.web.client.feign.TraceFeignClient 包括创建span一些参数

xiaomin0322
16分钟前
2
0
Less 延伸

extend 是一个 Less 伪类,它通过使用 :extend 选择器在一个选择器中扩展其他选择器样式。 扩展语法 扩展可以是附加到选择器,也可以是集中放置在规则,看上去像是带有选择器参数的可选伪类,...

凌兮洛
17分钟前
2
0
RedHat 7.0系统中安装mysql 5.7.22

在安装之前,首先要查看的是,你的系统中有没有已经安装过的情况。键入rpm -qa|grep mysql,如果无任何显示,则表示没有安装过相关组件,如果有,则根据显示出来的名字,键入rpm -e --nodeps...

最菜最菜之小菜鸟
22分钟前
2
0
RPA:企业信息孤岛的“克星”

为了降本增效,近来世界范围内掀起一股流程优化的热潮,转型升级成为众多企业时刻挂在嘴边的热词。不过在企业数字化转型的过程中,信息孤岛的出现,往往成为了企业升级的绊脚石。 信息孤岛:...

UiBot
22分钟前
2
0
我的测试

我的测试

daiison
22分钟前
2
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部