如何设置mysql root的密码,适用于5.6版本的。
来源:互联网 发布:上海大学云计算 编辑:程序博客网 时间:2024/04/30 07:26
如何设置mysql root密码:
1、首次安装 root初始密码为空,注意就是没有密码,直接敲回车即可进入
D:\wamp\bin\mysql\mysql5.6.17\bin>mysql -uroot -p
Enter password: [直接回车]
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.6.17 MySQL Community Server (GPL)
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>
2、修改root密码的几种方法:
1) 用SET PASSWORD命令
首先登录MySQL。
格式:mysql> set password for 用户名@localhost = password('新密码');
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
D:\wamp\bin\mysql\mysql5.6.17\bin>mysql -uroot -proot
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 8
Server version: 5.6.17 MySQL Community Server (GPL)
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>
2)用mysqladmin
格式:mysqladmin -u用户名 -p旧密码 password 新密码
例如:
D:\wamp\bin\mysql\mysql5.6.17\bin>mysqladmin -uroot -proot password root123
Warning: Using a password on the command line interface can be insecure.
D:\wamp\bin\mysql\mysql5.6.17\bin>mysql -uroot -proot123
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 10
Server version: 5.6.17 MySQL Community Server (GPL)
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>
3)用UPDATE直接编辑user表
首先登录MySQL。
mysql> use mysql;
mysql> update user set password=password('root') where user='root' and host='localhost';
mysql> flush privileges;
--注意一定要flush privileges;
mysql 新设置用户或更改密码后需用flush privileges刷新MySQL的系统权限相关表,否则会出现拒绝访问,还有一种方法,就是重新启动mysql服务器,来使新设置生效。
4)在忘记root密码的时候,可以这样。
以windows为例:
1. 关闭正在运行的MySQL服务。
2. 打开DOS窗口,转到mysql\bin目录。
3. 输入mysqld --skip-grant-tables 回车。--skip-grant-tables 的意思是启动MySQL服务的时候跳过权限表认证。
4. 再开一个DOS窗口(因为刚才那个DOS窗口已经不能动了),转到mysql\bin目录。
5. 输入mysql回车,如果成功,将出现MySQL提示符 >。
6. 连接权限数据库: use mysql; 。
6. 改密码:update user set password=password('root123') where user='root';(别忘了最后加分号) 。
7. 刷新权限(必须步骤):flush privileges;
8. 退出quit当前cmd,并且关闭2中的DOS窗口
1、首次安装 root初始密码为空,注意就是没有密码,直接敲回车即可进入
D:\wamp\bin\mysql\mysql5.6.17\bin>mysql -uroot -p
Enter password: [直接回车]
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.6.17 MySQL Community Server (GPL)
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>
2、修改root密码的几种方法:
1) 用SET PASSWORD命令
首先登录MySQL。
格式:mysql> set password for 用户名@localhost = password('新密码');
例如:
mysql> set password for root@localhost = password('root');Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
D:\wamp\bin\mysql\mysql5.6.17\bin>mysql -uroot -proot
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 8
Server version: 5.6.17 MySQL Community Server (GPL)
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>
2)用mysqladmin
格式:mysqladmin -u用户名 -p旧密码 password 新密码
例如:
D:\wamp\bin\mysql\mysql5.6.17\bin>mysqladmin -uroot -proot password root123
Warning: Using a password on the command line interface can be insecure.
D:\wamp\bin\mysql\mysql5.6.17\bin>mysql -uroot -proot123
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 10
Server version: 5.6.17 MySQL Community Server (GPL)
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>
3)用UPDATE直接编辑user表
首先登录MySQL。
mysql> use mysql;
mysql> update user set password=password('root') where user='root' and host='localhost';
mysql> flush privileges;
--注意一定要flush privileges;
mysql 新设置用户或更改密码后需用flush privileges刷新MySQL的系统权限相关表,否则会出现拒绝访问,还有一种方法,就是重新启动mysql服务器,来使新设置生效。
4)在忘记root密码的时候,可以这样。
以windows为例:
1. 关闭正在运行的MySQL服务。
2. 打开DOS窗口,转到mysql\bin目录。
3. 输入mysqld --skip-grant-tables 回车。--skip-grant-tables 的意思是启动MySQL服务的时候跳过权限表认证。
4. 再开一个DOS窗口(因为刚才那个DOS窗口已经不能动了),转到mysql\bin目录。
5. 输入mysql回车,如果成功,将出现MySQL提示符 >。
6. 连接权限数据库: use mysql; 。
6. 改密码:update user set password=password('root123') where user='root';(别忘了最后加分号) 。
7. 刷新权限(必须步骤):flush privileges;
8. 退出quit当前cmd,并且关闭2中的DOS窗口
9. 使用用户名root,新密码root123在4中DOS窗口登录。
0 0
- 如何设置mysql root的密码,适用于5.6版本的。
- 设置mysql 的root密码
- 如何设置Linux MySQL数据库 root用户的密码
- 如何设置mysql root密码
- ubuntu 9.10 设置MYSQL的ROOT密码
- CentOS下设置MySQL的root密码
- CentOS中设置MySQL的root密码
- Mac 重新设置MySQL的root密码
- 重新设置MySQL的root密码:
- 重新设置MySQL的root密码
- mysql 5.6忘记root密码之后如何重新设置密码
- 如何修改mysql的root密码
- 如何取回mysql的root密码
- 如何修改mysql的root密码
- 如何修改MYSQL的root密码
- 忘记MySql的root密码如何修改
- 如何去修改mysql root的密码
- 如何修改mysql的root密码
- 经典算法——堆排序笔试题
- 使用UIWebView 有些网页加载卡顿 内存还飙升的可别厉害
- mybatis批量插入oracle解决方法
- Ajax 与后台 HttpServlet 的简单交互
- Android 5.0 Material 自定义Dialog 背景 字体大小颜色 ui组件颜色
- 如何设置mysql root的密码,适用于5.6版本的。
- IOS开发中,SVN如何恢复到某一个版本(以Cornerstone为例)
- (原创)命令行查看md5key、sha1值、keystroe别名等信息
- java安全-安全管理器
- androidstudio 忽略文件
- GeoHash核心原理解析 附近的人算法
- uboot2010.3关于LCD输出的处理-LCD初始化设置
- 用户统计
- 拯救无法启动的虚拟机文件.vmdk中的数据