您的位置:首页 > 数据库 > MySQL

mysql登录失败

2016-01-02 12:29 531 查看
启动服务:

1.启动服务时遇到安全问题:

[root@bogon init.d]# ./mysqld

2016-01-02T03:05:31.522149Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2016-01-02T03:05:31.674951Z 0 [Note] ./mysqld (mysqld 5.7.10) starting as process 2756 ...

2016-01-02T03:05:32.035580Z 0 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

2016-01-02T03:05:32.038039Z 0 [ERROR] Aborting

2016-01-02T03:05:32.052689Z 0 [Note] Binlog end

2016-01-02T03:05:32.082019Z 0 [Note] ./mysqld: Shutdown complete

解决办法指定root用户启动。

[root@bogon init.d]# ./mysqld --user=root

2.执行 mysqladmin 失败

[root@bogon init.d]# mysqladmin -u root -p 123456

Enter password:

mysqladmin: connect to server at 'localhost' failed

error: 'Access denied for user 'root'@'localhost' (using password: NO)'

[root@bogon init.d]#

[root@bogon init.d]# mysql

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

解决办法:

--skip-grant-tables。 顾名思义,就是在启动mysql时不启动grant-tables,授权表。有什么用呢?当然是忘记管理员密码后有用。

[root@bogon init.d]#./mysqld --user=root --skip-grant-tables

3.修改密码

mysql>use mysql;

mysql>update mysql.user set authentication_string=password('123456') where user='root' and Host ='localhost';

mysql>flush privileges;

mysql>exit
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: