• Access denied for user 'root'@'localhost' (using password:YES)


    版权所有,未经博主允许不得转载。

    今天发现服务器mysql连接不上,报

    can't connect to mysql server on 'root'@'ip' (61)

    照例ssh到服务器,发现mysql也进入不了,报错Access denied for user 'root'@'localhost' (using password:YES), 以前都是可以的(好几次出现这种情况)。今天整理下--系统linux. mysql 5.5

    谷歌了下,发现解决方法:

    1、首先查看mysql 3306端口是否打开。。命令

    netstat -an | grep 3306

    这个时候发现3306监听的确没有开启。so这个时候停掉mysql服务。命令

    /etc/init.d/mysql stop

    查看mysql是否停掉,命令

    ps -ax |grep mysql

    若停掉,则不会看到mysql进程

    若未停掉,多试几次

    2、then启动mysql,mysqld_safe方式进入mysql  命令

    mysqld_safe --user=mysql &
    
    #mysql -u root
    
    mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
    mysql>FLUSH PRIVILEGES;

    重启mysql

    #/etc/init.d/mysql restart
    
    #mysql -u root -p
    
    Enter password:

    mysql远程登录授权grant命令

    命令:

    grant all privileges on *.* to 'USER'@'IP' identified by 'PASS' 

    USER:登录用户名

    PASS:密码

    IP:ip地址或主机号

    *.*:数据库.数据表名 

    all privileges:所有权限 也可为select,insert ,update,delete

    整理下,以被以后遇到又浪费太多时间。

  • 相关阅读:
    Python configparser模块
    Python OS,shutil模块
    一、操作系统基础
    Python 序列化
    Python 验证码生产程序和进度条程序
    SaltStack 实践课程二 PHP+NGINX
    Android攻城狮数据存储之文件存储
    Android攻城狮数据存储之SQLite数据库简介
    Android攻城狮数据存储之SharedPreferences
    Android攻城狮读取了JSON实现图文混排
  • 原文地址:https://www.cnblogs.com/symen/p/5715273.html
Copyright © 2020-2023  润新知