LAMP搭建20:MySQL重置root密码
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了LAMP搭建20:MySQL重置root密码,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含4107字,纯文字阅读大概需要6分钟。
内容图文
![LAMP搭建20:MySQL重置root密码](/upload/InfoBanner/zyjiaocheng/474/97bad26288784a9baab7aba5cdf26924.jpg)
[root@centos6 ~]# mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.1.49 MySQL Community Server (GPL)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
mysql>
可以使用mysqladmin工具的password选项给root用户添加密码:
[root@centos6 ~]# mysqladmin -uroot password ‘654321‘
设置密码后,不输入密码将登陆失败:
[root@centos6 ~]# mysql -uroot
ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO)
[root@centos6 ~]# mysql -uroot -p654321
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.1.49 MySQL Community Server (GPL)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
mysql>
重置root密码需要编辑配置文件,加入一条语句:skip-grant:
[root@centos6 ~]# vim /etc/my.cnf
……
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
# Try number of CPU‘s*2 for thread_concurrency
thread_concurrency = 8
skip-grant
……
重启MySQL
[root@centos6 ~]# mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
此时不需要密码即可登录
[root@centos6 ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.49 MySQL Community Server (GPL)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
mysql>
使用mysql库
mysql> use mysql
Database changed
更改user表中root的密码为aming.com
mysql> update user set password=password(‘123456‘) where user=‘root‘;
Query OK, 3 rows affected (0.01 sec)
Rows matched: 3 Changed: 3 Warnings: 0
查看user表中root的信息,\G看起来整洁:
mysql> select * from user where user=‘root‘ \G;
*************************** 1. row ***************************
Host: localhost
User: root
Password: *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9
Select_priv: Y
Insert_priv: Y
Update_priv: Y
Delete_priv: Y
Create_priv: Y
Drop_priv: Y
Reload_priv: Y
Shutdown_priv: Y
Process_priv: Y
File_priv: Y
Grant_priv: Y
References_priv: Y
Index_priv: Y
Alter_priv: Y
Show_db_priv: Y
Super_priv: Y
Create_tmp_table_priv: Y
Lock_tables_priv: Y
Execute_priv: Y
Repl_slave_priv: Y
Repl_client_priv: Y
Create_view_priv: Y
Show_view_priv: Y
Create_routine_priv: Y
Alter_routine_priv: Y
Create_user_priv: Y
Event_priv: Y
Trigger_priv: Y
ssl_type:
ssl_cipher:
x509_issuer:
x509_subject:
max_questions: 0
max_updates: 0
max_connections: 0
max_user_connections: 0
……
退出MySQL,编辑配置文件,删除skip-grant行,重启MySQL,再次登录即可使用新密码登录。
[root@centos6 ~]# vim /etc/my.cnf
[root@centos6 ~]# mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
[root@centos6 ~]# mysql
ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO)
[root@centos6 ~]# mysql -uroot -p123456
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.49 MySQL Community Server (GPL)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
mysql>
LAMP搭建20:MySQL重置root密码
标签:lamp mysql 重置 root密码
本文系统来源:http://rachy.blog.51cto.com/11428504/1892329
内容总结
以上是互联网集市为您收集整理的LAMP搭建20:MySQL重置root密码全部内容,希望文章能够帮你解决LAMP搭建20:MySQL重置root密码所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。