MYSQL登录错误:mysqladmin: connect to server
2016-06-07 00:27
609 查看
最近安装mysql后,由于默认密码为空,也登陆不了,通过 mysqladmin –u root password 无法设置密码,一直提示如下错误
解决办法如下:
--skip-grant-tables:不启动grant-tables(授权表),跳过权限控制的作用
还有一直方式就是在my.cnf配置文件中添加 skip-grant-tables
成功登录mysql后就可以修改密码了,操作如下:
修改密码后确实可以登录了,当是登录基本上啥做不了,还需要重新设置一下密码
ps:视乎我这个版本( 5.7.13 )的密码限定了密码规则,导致纯数字、纯字母都设置不成功,我估摸着至少必须包含字母大小写加数字吧。
[code=language-bash][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(授权表),跳过权限控制的作用
[code=language-bash][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
[code=language-bash][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后就可以修改密码了,操作如下:
[code=language-bash]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>
修改密码后确实可以登录了,当是登录基本上啥做不了,还需要重新设置一下密码
[code=plain]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 requirement 3ff0 s 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 )的密码限定了密码规则,导致纯数字、纯字母都设置不成功,我估摸着至少必须包含字母大小写加数字吧。
相关文章推荐
- J2ee项目从0搭建(七):集成Mybatis、mybatis-generator代码生成、MySQL数据库
- MySQL 的日常使用
- Xtrabackup实现MySQL每天自动热备
- MySQL管理一些基础SQL语句
- MySql-主从复制
- Spark(九):Spark SQL访问Hive,MySQL
- MySql优化的一般步骤
- Mysql表操作和 DECIMAL(N,M)数据类型
- lnmp 忘记mysql密码
- mysql查询优化
- mysql单机多实例
- mysql中创建字符集为utf-8的数据库
- MySQL数据库mysqlcheck的使用方法
- 安装MySQL5.5的错误Error Nr.1045解决方案
- Ubuntu mysql安装,还有可视化界面
- center os 安装mysql5.6
- MySQL 开启远程访问
- mysql一些使用技巧
- mysql常用基础操作语法(一)~~对库的操作【命令行模式】
- mysql导sql文件