zoukankan      html  css  js  c++  java
  • 阿里云安装mysql,初始化密码修改

    阿里云服务器,centos7,

    rpm包安装MySQL,初始化了个奇葩密码

    登陆不上,

    1. 修改配置文件/etc/my.cnf,在【mysqld】下面添加一行代码:skip-grant-tables
    2. service mysqld restart
    3. mysql -uroot -p  //此时直接回车,既可以进入数据库。
    4. 进数据库后,use mysql   //选择mysql这个库,因为mysql的root密码存放在这个数据库里。
    5. show tables  //查看下mysql库里有哪些表,我们需要操作的用户名密码都在user表里。
    6. desc user  //查看下user表有哪些字段。
    7. update user set password=password('123456') where user="root";  //用户选root,可以随便更改成任意密码,我这里设置的123456,password()是mysql密码加密的一个函数。有些数据要执行update user set authentication_string=password('coship') where user="root";才行
    8. 发现行不通,
    9. 改用ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
    10. 报错:The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
    11. flush privileges;
    12. 再次:ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
    13. ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
    14. 执行:SHOW VARIABLES LIKE 'validate_password%';
    15. set global validate_password.policy=0;set global validate_password.length=6;
    16. 然后再次执行:ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
    17. Query OK, 0 rows affected (0.03 sec)
    18. over
  • 相关阅读:
    重载小于号
    无聊的会议
    程序内存和时间
    对拍
    读入和输出优化
    codevs 3269 混合背包
    清北第三套题
    codevs 2188 最长上升子序列
    清北第二套题
    [COGS896] 圈奶牛
  • 原文地址:https://www.cnblogs.com/a-s-m/p/12232945.html
Copyright © 2011-2022 走看看