SQL Life

修改MySql用户密码

时间:2014/7/9 21:43:44  作者:solgle  来源:www.solgle.com  查看:2846  评论:0
内容摘要:方法一:[root@www.solgle.com var]# mysql -h localhost -u root -p Enter password:圀攀氀挀漀洀攀 to the MySQL monitor. Commands end with ; or \g...
方法一:
本文出自;http://www.solgle.com/news/?136.html
[root@www.solgle.com var]# mysql -h localhost -u root -p        
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 5.6.20-enterprise-commercial-advanced MySQL Enterprise Server - 
 
Advanced Edition (Commercial)
 
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> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
 
Database changed
mysql> SET PASSWORD FOR root=password('111111');
Query OK, 0 rows affected (0.00 sec)
 
mysql> quit
Bye
[root@www.solgle.com var]# 
 
方法二:
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
 
Database changed
mysql> update user set password=password('111111') where user='root';
Query OK, 0 rows affected (0.03 sec)
Rows matched: 4  Changed: 0  Warnings: 0
 
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
 
mysql> quit
Bye
[root@www.solgle.com var]# 
 
方法三:
1:更改root之前有密码的情况
[root@www.solgle.com var]# mysqladmin -u root -p222222 password "111111";
Warning: Using a password on the command line interface can be insecure.
[root@www.solgle.com var]# 
 
2:更改之前root还没有密码
###[root@www.solgle.com var]# mysqladmin -u root -p111111 password "";
###Warning: Using a password on the command line interface can be insecure.
 
[root@www.solgle.com var]# mysqladmin -u root password "222222";  
Warning: Using a password on the command line interface can be insecure.
[root@www.solgle.com var]# 
 
 
创建一个用户test,对数据库solgle-db有权限
mysql> grant all on solgle-db.* to test identified by "111111";
Query OK, 0 rows affected (0.01 sec)
mysql> exit
Bye
 
 
---测试该用户
[root@www.solgle.com var]# mysql -u test -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 47
Server version: 5.6.20-enterprise-commercial-advanced MySQL Enterprise Server - 
 
Advanced Edition (Commercial)
 
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> select count(1) from user;
ERROR 1046 (3D000): No database selected
 
mysql> use mysql
ERROR 1044 (42000): Access denied for user 'test'@'%' to database 'mysql'
 
mysql> use solgle-db
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
 
mysql> select count(1) from user;
ERROR 1146 (42S02): Table 'solgle-db.user' doesn't exist
mysql> select count(1) from users;
ERROR 1146 (42S02): Table 'solgle-db.users' doesn't exist
mysql> select count(1) from Users;
+----------+
| count(1) |
+----------+
|        3 |
+----------+
1 row in set (0.01 sec)
mysql> 
 
--从上面可以看出表名是要区分大小写的
 
 
标签:修改mysql密码 修改mysql用户密码 

solgle.com 版权所有,欢迎分享!!!

上一篇:MySql for Linux部署文档
下一篇:没有了
相关文章
    相关评论
     img1 img2 img3 img4 img5 img6 img7 img8 img9 img10
    评论者:      验证码:  点击获取验证码
       Copyright © 2013-2028 solgle.com,All rights reserved.[solgle.com] 公安机关备案号:51010802000219
    Email:solgle@solgle.com; weixin:cd1008610000 ICP:蜀ICP备14011070号-1