Home > Database > Mysql Tutorial > body text

MySql使用全记录4

WBOY
Release: 2016-06-07 15:46:26
Original
1009 people have browsed it

设置MySql的root用户口令 本文由CSDN- 蚍蜉撼青松 【主页: http://blog.csdn.net/howeverpf 参考链接 : http://wenku.baidu.com/view/73ab05737fd5360cba1adb08.html 安装好MySql服务以后,默认已有root用户,其默认密码为空,此时不使用口令即可登入。出

设置MySql的root用户口令

本文由CSDN-蚍蜉撼青松【主页:http://blog.csdn.net/howeverpf

 

参考链接http://wenku.baidu.com/view/73ab05737fd5360cba1adb08.html

 

 

        安装好MySql服务以后,默认已有root用户,其默认密码为空,此时不使用口令即可登入。出于安全性考虑,我们需要设置数据库用户root的登录密码。

1.使用grant语句

        使用root和空密码进入mysql提示符,输入如下:

mysql>grant all on *.* to 'root'@'localhost' IDENTIFIED BY '新口令' with grant option;
Copy after login

2.使用set password命令

        使用root和空密码进入mysql提示符,输入如下:

mysql>set password for 'root'@'localhost'= password('新口令');
Copy after login

        命令的格式为,SET PASSWORD FOR '用户名'@'主机名' = PASSWORD('口令');        若要允许远程登录,则主机名写为%

3.进入mysql库修改user表

        使用root和空密码进入mysql提示符,输入如下:

mysql>use mysql;
mysql>update user set password = password('新口令') where user = 'root';
mysql>flush privileges;
Copy after login

4.使用mysqladmin

        前提上是安装完毕后,去MySQL的bin目录下,看是否存在mysqladmin.exe这个可执行文件,有则可用此方法,木有就算了。(我在Win7上用wamp装的就没这工具)

        在mysqladmin.exe所在的目录下打开命令提示符(摁住shift后点鼠标右键),输入:

mysqladmin -uroot -p password 新口令
Enter password: ****                      //刚安装后为空,直接回车即可
Copy after login

 

 

------本文由CSDN-蚍蜉撼青松【主页:http://blog.csdn.net/howeverpf------

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!