zoukankan      html  css  js  c++  java
  • linux平台mysql密码设置

    登录mysql默认没有指定账号

     

    查看默认账号是谁

    select user();
    mysql> select user();
    +----------------+
    | user() |
    +----------------+
    | ODBC@localhost |
    +----------------+
    1 row in set (0.03 sec)

    默认账号是 ODBC

     

    切换mysql账号

     

    -u 指定mysql账号

    -p 指定mysql密码

     

    mysql -uroot -p

    mysql -uroot -p -h127.0.0.1
    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 236589218
    Server version: 5.6.20-log Source distribution
    
    Copyright (c) 2000, 2014, 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> 
    mysql> select user();
    +----------------+
    | user()         |
    +----------------+
    | root@localhost |
    +----------------+
    1 row in set (0.00 sec)

    登录设置密码

    初始状态下,管理员root,密码为空,默认只允许从本机登录localhost

     
    设置初始密码
    mysqladmin -uroot password "123"        设置初始密码 由于原密码为空,因此-p可以不用

    也可以设置-p

    
    
    mysqladmin -uroot -p password "123"




    [root@mysql ~]# mysql -uroot -p
    Enter password: 
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
    [root@mysql ~]# mysql -uroot -p123
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 6
    Server version: 5.1.73 Source distribution
    
    Copyright (c) 2000, 2013, 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> 
    修改mysql密码
    mysqladmin -uroot -p"123" password "456"        修改mysql密码,因为已经有密码了,所以必须输入原密码才能设置新密码
     
     
     
  • 相关阅读:
    Asp.net实现URL重写
    IHttpModule不起作用的两个原因
    从客户端中检测到有潜在危险的 request.form值[解决方法]
    PHP $_SERVER详解
    string.Format 格式化日期格式
    图解正向代理、反向代理、透明代理
    Javacard 解释器怎样在API类库中找到源文件调用的类、方法或者静态域?
    API
    指令集
    机器码与字节码
  • 原文地址:https://www.cnblogs.com/mingerlcm/p/9745458.html
Copyright © 2011-2022 走看看