如何设置mysql root密码
来源:互联网 发布:淘宝客软件开发 编辑:程序博客网 时间:2024/04/29 05:08
如何设置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('新密码');
例如:
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窗口登录。
-----------------------------
Dylan Presents.
0 0
- 如何设置mysql root密码
- mysql忘记root密码如何重新设置
- mysql root 设置密码
- mysql 设置root密码
- mysql设置root密码
- mysql --设置root 密码
- mysql设置root密码
- MySql设置root密码
- mysql 5.6忘记root密码之后如何重新设置密码
- 如何设置Linux MySQL数据库 root用户的密码
- Mysql安装好后root没有密码如何设置
- 如何设置mysql root的密码,适用于5.6版本的。
- 设置mysql root账户密码
- mysql用户密码设置,root密码
- 设置mysql 的root密码
- liunx mysql 设置root密码
- centos设置mysql root密码
- 如何修改MySQL root密码
- 整合Flex和J2EE
- 第七章 右左法则----复杂指针解析
- TCP二进制流接收
- 【LeetCode】Merge Sorted Array
- JSBadgeView适配iOS7、8,和超快速使用
- 如何设置mysql root密码
- C# DEV RepositoryItemRadioGroup GridView
- [学习小结]Mybaits与Spring的集成
- 【Android】Paint的效果研究
- RAC 管理(crs_stat、crsctl、srvctl)
- java设计模式之——策略模式
- C语言求最大公约数和最小公倍数算法
- Java实践 — SSH远程执行Shell脚本
- MySQL-11-存储过程