码迷,mamicode.com
首页 > 数据库 > 详细

【MySQL】设置MySQL密码

时间:2015-07-04 09:50:31      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:centos 7.1 mysql password

// 启动MySQL

[root@wode006 tools]# systemctl start mysqld



// 以root连接到MySQL

[root@wode006 tools]# mysql -u root

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 8

Server version: 5.6.25 MySQL Community Server (GPL)


Copyright (c) 2000, 2015, 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,host,password from mysql.user

    -> ;

+------+-----------+----------+

| user | host      | password |

+------+-----------+----------+

| root | localhost |          |

| root | 127.0.0.1 |          |

| root | ::1       |          |

|      | localhost |          |

+------+-----------+----------+

4 rows in set (0.00 sec)


mysql> 


// 设置密码

mysql> set password for root@localhost=password(‘your-password‘);

Query OK, 0 rows affected (0.00 sec)



// 查看密码

mysql> select user,host,password from mysql.user;

+------+-----------+-------------------------------------------+

| user | host      | password                                  |

+------+-----------+-------------------------------------------+

| root | localhost | *21ACDCFEB260C9C42B0FC5E5DC741C453A48C99D |

| root | 127.0.0.1 |                                           |

| root | ::1       |                                           |

|      | localhost |                                           |

+------+-----------+-------------------------------------------+

4 rows in set (0.00 sec)



// 退出MySQL

mysql> exit

Bye


// 重新登录MySQL

[root@wode006 tools]# mysql -u root -p

Enter password: 

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 9

Server version: 5.6.25 MySQL Community Server (GPL)



【MySQL】设置MySQL密码

标签:centos 7.1 mysql password

原文地址:http://huangchao.blog.51cto.com/10446378/1670744

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!