Home Database Mysql Tutorial 如何修改MySQL数据库的密码_MySQL

如何修改MySQL数据库的密码_MySQL

Jun 01, 2016 pm 01:53 PM
root authority how yes user

  注释:在大多数的情况下,修改MySQL是需要有mySQL里的root权限的,所以一般用户无法更改密码,除非请求管理员。

  方法1

  使用phpmyadmin,这是最简单的了,修改mySQL库的user表,

  不过别忘了使用PASSWORD函数。

  方法2

  使用mySQLadmin,这是前面声明的一个特例。

mySQLadmin -u root -p password mypasswd

  输入这个命令后,需要输入root的原密码,然后root的密码将改为mypasswd。

  把命令里的root改为你的用户名,你就可以改你自己的密码了。

  当然如果你的mysqladmin连接不上mysql server,或者你没有办法执行mySQLadmin,

  那么这种方法就是无效的。 而且mySQLadmin无法把密码清空。

  下面的方法都在mysql提示符下使用,且必须有mySQL的root权限:

  方法3

mysql> INSERT INTO mysql.user (Host,User,Password)
VALUES(%,jeffrey,PASSWORD(iscuit));
   mySQL> FLUSH PRIVILEGES

  确切地说这是在增加一个用户,用户名为jeffrey,密码为biscuit。在《mySQL中文参考手册》里有这个例子,所以我也就写出来了。 注意要使用PASSWORD函数,然后还要使用FLUSH PRIVILEGES。

  方法4

  和方法三一样,只是使用了REPLACE语句

mysql> REPLACE INTO mysql.user (Host,User,Password)
VALUES(%,jeffrey,PASSWORD(iscuit));
   mySQL> FLUSH PRIVILEGES

  方法5

  使用SET PASSWORD语句,

mySQL> SET PASSWORD FOR jeffrey@"%" = PASSWORD(iscuit);

  你也必须使用PASSWORD()函数,

  但是不需要使用FLUSH PRIVILEGES。

  方法6

  使用GRANT ... IDENTIFIED BY语句

mySQL> GRANT USAGE ON *.* TO jeffrey@"%" IDENTIFIED BY iscuit

  这里PASSWORD()函数是不必要的,也不需要使用FLUSH PRIVILEGES。

  注意: PASSWORD() [不是]以在Unix口令加密的同样方法施行口令加密。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use Xiaohongshu account to find users? Can I find my mobile phone number? How to use Xiaohongshu account to find users? Can I find my mobile phone number? Mar 22, 2024 am 08:40 AM

How to use Xiaohongshu account to find users? Can I find my mobile phone number?

Local users and groups are missing on Windows 11: How to add it Local users and groups are missing on Windows 11: How to add it Sep 22, 2023 am 08:41 AM

Local users and groups are missing on Windows 11: How to add it

Log in to Ubuntu as superuser Log in to Ubuntu as superuser Mar 20, 2024 am 10:55 AM

Log in to Ubuntu as superuser

Explore Windows 11 guide: How to access user folders on your old hard drive Explore Windows 11 guide: How to access user folders on your old hard drive Sep 27, 2023 am 10:17 AM

Explore Windows 11 guide: How to access user folders on your old hard drive

Where to enable root permissions in vmos Where to enable root permissions in vmos Feb 27, 2024 pm 03:16 PM

Where to enable root permissions in vmos

What is sudo and why is it important? What is sudo and why is it important? Feb 21, 2024 pm 07:01 PM

What is sudo and why is it important?

Windows 11 KB5031455 fails to install, causing other issues for some users Windows 11 KB5031455 fails to install, causing other issues for some users Nov 01, 2023 am 08:17 AM

Windows 11 KB5031455 fails to install, causing other issues for some users

Tutorial: How to delete a normal user account in Ubuntu system? Tutorial: How to delete a normal user account in Ubuntu system? Jan 02, 2024 pm 12:34 PM

Tutorial: How to delete a normal user account in Ubuntu system?

See all articles