1. mysql安装后默认没有密码,初始化安装后默认密码登录,需要马上修改root密码。
[root@mysql ~]# cat /root/.mysql_secret    --查看root账号密码
# The random password set for the root user at Tue Dec 13 18:59:06 2016 (local time): 7MhtyX3aZEl9OUf8
[root@mysql ~]# mysql -uroot -p    -- 登录mysql
Enter password:               --(此处复制粘贴 7MhtyX3aZEl9OUf8)
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.25
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>   表示一切顺利成功。

2.  修改密码
mysql> SET PASSWORD = PASSWORD('123456');   --设置密码为123456
[root@mysql etc]# mysql -uroot -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 39
Server version: 5.6.25 MySQL Community Server (GPL)
mysql>     --登录成功

3. 忘记mysql数据库root的密码后,如何修改密码。
[root@mysql etc]# service mysql stop   --停止mysql进程
Shutting down MySQL.... SUCCESS! 
[root@mysql etc]# mysqld_safe --skip-grant-tables&  --启动mysql时不启动grant-tables,授权表。执行后出现下面画面,另起一个新会话。
[1] 3574
[root@mysql etc]# 161215 06:13:53 mysqld_safe Logging to '/var/lib/mysql/mysql.err'.
161215 06:13:53 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
[root@mysql ~]# ps -ef|grep mysql   --查看mysql进程是否起来
root       3467   3440  0 05:29 pts/2    00:00:00 mysql -uandy -px xx
root       3574   2845  0 06:13 pts/0    00:00:00 /bin/sh /usr/bin/mysqld_safe --skip-grant-tables
mysql      3677   3574  2 06:13 pts/0    00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-
mysql> UPDATE user SET password=PASSWORD('cccccc') WHERE user='root';   --更改root密码
Query OK, 4 rows affected (0.04 sec)
Rows matched: 4  Changed: 4  Warnings: 0
mysql> FLUSH PRIVILEGES;    --权限更新
Query OK, 0 rows affected (0.00 sec)
[root@mysql ~]# mysql -uroot -p123456    --使用旧密码登录,发现不行,说明密码已经更新
Warning: Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@mysql ~]# mysql -uroot -pcccccc   --新密码登录成功
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
mysql>

最新文章

  1. AngularJs自定义指令详解(5) - link
  2. 浅析for in 和for的区别
  3. Jquery学习笔记--性能优化建议
  4. POJ3694 Network
  5. Java 默认/缺省 server 还是 client 模式
  6. 《JavaScript高级程序设计》第4章 变量、作用域和内存问题
  7. Hibernate 中update hql语句
  8. js实现一个砖头在页面拖拉效果
  9. [Redux] Extracting Container Components -- VisibleTodoList
  10. PHP开发调试环境配置
  11. When Hybrid Cloud Meets Flash Crowd: Towards Cost-Effective Service Provisioning--INFOCOM 2015
  12. tornado框架源码分析---Application类之debug参数
  13. Python基础(文件操作)
  14. kbmmw中向服务器端传递对象的一种简单方式
  15. Hybrid设计--核心交互
  16. 【Vue.js实战案例】- Vue.js递归组件实现组织架构树和选人功能
  17. 快速升级PHP5.4、MySql5.5版本WDCP面板一键包
  18. 数据仓库基础(三)OLAP
  19. 详解Tomcat配置及使用
  20. 资料汇总--java开发程序员必备技能

热门文章

  1. Android布局— — —表格布局
  2. 玩转渗透神器Kali:Kali Linux作为主系统使用的正确姿势TIPS
  3. (转)IOS之Info.plist文件简介
  4. OC中修饰符:宏define 常量:const extern
  5. List<T>转换为DataTable
  6. MVC - Code First Migration Command line
  7. 转:通过代码理解Asp.net4中的几种ClientIDMode设置.
  8. 关于cocos2d-x 与 cocos2d-html5 资源预加载的思考
  9. OpenvSwitch架构
  10. (实用篇)微信网页授权(OAuth2.0) PHP 源码简单实现