Mysql修改密码
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Mysql修改密码,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1904字,纯文字阅读大概需要3分钟。
内容图文
初次安装MySQL默认没有密码,安装完毕之后最好增加密码
1、命令
1 #/usr/bin/mysqladmin -u root password ‘new-password‘
格式:mysqladmin -u 用户名 -p 旧密码 password 新密码
2、例子
例1:给root加个密码admin
键入以下命令 :
1 [root@node1]# /usr/bin/mysqladmin -u root password admin
注:因为开始时root没有密码,所以-p旧密码一项就可以省略了。
3、测试是否修改成功
1)不用密码登录
1 [root@node1 /] # mysql
2 ERROR 1045: Access denied foruser: ‘root@localhost‘ (Using password: NO)
显示错误,说明密码已经修改。
2)用修改后的密码登录
1 [root@node1 /]# mysql -u root -p 2Enter password: (输入修改后的密码admin) Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 7
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
MariaDB [(none)]>
成功!
这是通过mysqladmin命令修改口令,也可通过修改库来更改口令。
4)再次修改密码
1 [root@node1 /]# mysql -u root -p 2 Enter password: (输入修改后的密码admin)
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 28
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
MariaDB [(none)]> 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
MariaDB [mysql]> set password=password(‘123456‘);
Query OK, 0 rows affected (0.00 sec)
MariaDB [mysql]> exit
Bye
5)用再次修改后的密码登录
1 [root@node1 /]# mysql -u root -p 2 Enter password: (输入再次修改后的密码)
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 29
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
MariaDB [(none)]>
登录成功!
原文:https://www.cnblogs.com/kiko-sunrise/p/10984826.html
内容总结
以上是互联网集市为您收集整理的Mysql修改密码全部内容,希望文章能够帮你解决Mysql修改密码所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。