MySQL修改密码
2015-08-19 15:07
656 查看
A
be set several ways. The following discussion demonstrates three methods:
Use the
Use the
Use the mysqladmin command-line
client program
To assign passwords using
issue a
listed in the
For Unix, do this:
mysql>
mysql>
mysql>
mysql>
[/code]
You can also use a single statement that assigns a password to all
by using
modify the
directly. This method works on any platform:
mysql>
->
mysql>
[/code]
The
causes the server to reread the grant tables. Without it, the password change remains unnoticed by the server until you restart it.
To assign passwords to the
using mysqladmin,
execute the following commands:
shell>
[/code]
Those commands apply both to Windows and to Unix. The double quotation marks around the password are not always necessary, but you should use them if the password contains spaces or other characters that are special to your command interpreter.
The mysqladmin method
of setting the
passwords does not work for the
Use the
rootaccount password can
be set several ways. The following discussion demonstrates three methods:
Use the
SET PASSWORDstatement
Use the
UPDATEstatement
Use the mysqladmin command-line
client program
To assign passwords using
SET PASSWORD, connect to the server as
rootand
issue a
SET PASSWORDstatement for each
rootaccount
listed in the
mysql.usertable.
For Unix, do this:
shell> [code]mysql -u root
mysql>
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd');
mysql>
SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('newpwd');
mysql>
SET PASSWORD FOR 'root'@'::1' = PASSWORD('newpwd');
mysql>
SET PASSWORD FOR 'root'@'host_name' = PASSWORD('
newpwd');
[/code]
You can also use a single statement that assigns a password to all
rootaccounts
by using
UPDATEto
modify the
mysql.usertable
directly. This method works on any platform:
shell> [code]mysql -u root
mysql>
UPDATE mysql.user SET Password = PASSWORD('newpwd')
->
WHERE User = 'root';
mysql>
FLUSH PRIVILEGES;
[/code]
The
FLUSHstatement
causes the server to reread the grant tables. Without it, the password change remains unnoticed by the server until you restart it.
To assign passwords to the
rootaccounts
using mysqladmin,
execute the following commands:
shell> [code]mysqladmin -u root password "newpwd"
shell>
mysqladmin -u root -h host_namepassword "
newpwd"
[/code]
Those commands apply both to Windows and to Unix. The double quotation marks around the password are not always necessary, but you should use them if the password contains spaces or other characters that are special to your command interpreter.
The mysqladmin method
of setting the
rootaccount
passwords does not work for the
'root'@'127.0.0.1'or
'root'@'::1'account.
Use the
SET PASSWORDmethod shown earlier.
相关文章推荐
- 如何將 MySQL 資料庫轉移到 Microsoft SQL Server 與 Azure SQL Database
- Windows下MySQL備份與還原
- MySQL创建只读账号
- 报错:1130-host ... is not allowed to connect to this MySql server 开放mysql远程连接 不使用localhost
- Mysql不需要身份验证便可远程连接故障
- MYSQL备份与恢复
- mysql 并发下数据不一致的问题分析及解决
- mysql数据类型介绍(含text,longtext,mediumtext说明)
- mysql中update ..where 字段 in(..) 报You can't specify target table for update in FROM clause错误
- mysql实际使用思路
- 超越MySQL:三个流行MySQL分支的对比
- mysql除法精度
- 自动备份mysql数据库脚本,适用小量数据
- MySQL表达式计算
- Mysql-5.6安装编译全教程
- MySQL中出现乱码问题的终极解决宝典
- [慢查优化]联表查询注意谁是驱动表 & 你搞不清楚谁join谁更好时请放手让mysql自行判定
- Mysql-主从精简配置
- Mysql数据库索引查询优化的分享
- MySQL索引和查询优化的实际操作