zoukankan      html  css  js  c++  java
  • ubuntu安装mysql添加密码

    ubuntu安装mysql5.7后没有密码,添加密码。

    这里是关键点,由于mysql5.7没有password字段,密码存储在authentication_string字段中,password()方法还能用

    在mysql中执行下面语句修改密码

    show databases;
     
    use mysql;
      
    update user set authentication_string=PASSWORD("自定义密码") where user='root';
      
    update user set plugin="mysql_native_password";
      
    flush privileges;
      
    quit;

    Ubuntu 重置MySQL Root密1.停止MySQL服务

    $ service mysql stop

     

    2.跳过认证启动MySQL服务

    $ mysqld_safe --skip-grant-tables

    3.免密码登录MySQL

    $ mysql -u root

     mysql> use mysql;

    MySQL 5.7 以前版本

    mysql> update user set Password=PASSWORD('new_password') where user='root';

    MySQL 5.7 以后版本(Password字段改为了authentication_string)

    mysql> update user set authentication_string=PASSWORD('new_password') where user='root';

    mysql> flush privileges;

    mysql> exit;

    4.开启MySQL服务

    $ service mysql start

    5.使用刚刚重置的新密码登录

    $ mysql -u root -p 

  • 相关阅读:
    继承与多态,Instanceof关键字
    面向对象,单例模式
    方法
    数组
    流程控制
    基础语法
    连接linux四大远程工具
    MYSQL-索引的设计
    银行一类(Ⅰ类)、二类(Ⅱ类)、三类(Ⅲ类)账户区别是什么?
    真正有效的学习
  • 原文地址:https://www.cnblogs.com/shenZS/p/13541707.html
Copyright © 2011-2022 走看看