zoukankan      html  css  js  c++  java
  • Mysql 本地登陆和密码登陆

    mysql> create user czcb@'10.130.128.130' identified by '123456';
    Query OK, 0 rows affected (0.00 sec)
    
    -bash-4.1$ mysql -uczcb         
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 52
    Server version: 5.6.16 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> 
    
    -bash-4.1$ mysql -uczcb -p123456
    Warning: Using a password on the command line interface can be insecure.
    ERROR 1045 (28000): Access denied for user 'czcb'@'localhost' (using password: YES)
    
    
    新建用户后 客户端登陆会报1045错误
    
    mysql> grant select,insert,update on test.* to 'czcb'@'%';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> select host,user,password from mysql.user where user='czcb';
    +----------------+------+-------------------------------------------+
    | host           | user | password                                  |
    +----------------+------+-------------------------------------------+
    | 10.130.128.130 | czcb | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
    | %              | czcb |                                           |
    +----------------+------+-------------------------------------------+
    2 rows in set (0.00 sec)
    
    需要做:
    grant select,insert,update on test.* to 'czcb'@'%' identified by '123456';
    
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> select host,user,password from mysql.user where user='czcb';
    +----------------+------+-------------------------------------------+
    | host           | user | password                                  |
    +----------------+------+-------------------------------------------+
    | 10.130.128.130 | czcb | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
    | %              | czcb | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
    +----------------+------+-------------------------------------------+
    2 rows in set (0.00 sec)
    
    
    
    此时本地还是无法用密码登陆:
    -bash-4.1$ mysql -uczcb -p123456
    Warning: Using a password on the command line interface can be insecure.
    ERROR 1045 (28000): Access denied for user 'czcb'@'localhost' (using password: YES)
    
    
    grant select,insert,update on test.* to 'czcb'@localhost identified by '123456';
    
    
    
    此时可以:
    -bash-4.1$ mysql -uczcb -p123456
    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 96
    Server version: 5.6.16 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 host,user,password from mysql.user where user='czcb';
    +----------------+------+-------------------------------------------+
    | host           | user | password                                  |
    +----------------+------+-------------------------------------------+
    | 10.130.128.130 | czcb | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
    | %              | czcb | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
    | localhost      | czcb | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
    +----------------+------+-------------------------------------------+
    3 rows in set (0.00 sec)
    

  • 相关阅读:
    [概率论]2017.5.9
    [概率论] 2017 5.2
    [离散数学II]2017.5.2
    [离散数学II]2017.4.25
    [概率论]2017.4.19
    [概率论] 2017.4.18
    [离散数学II]2017.4.18
    [离散数学II]2017.4.11
    [概率论]2017.4.12
    [概率论]2017.4.5
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13351771.html
Copyright © 2011-2022 走看看