mysql5免安装版 配置文件my.cnf问题 感谢高手回答

来源:百度知道 编辑:UC知道 时间:2024/05/30 11:12:04
我把原始的 my-small.ini 修改了一处
==========修改前==================
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
============================

==========修改后==================
[client]
password = mypwd
port = 3306
socket = /tmp/mysql.sock
============================

大家看见啦: 我启用了密码
然后另存为my.cnf

然后登陆:
当然,登陆时(root用户)系统说要输入密码的,因为我启用了嘛,这可以理解
问题是:我输入mypwd,系统不让进,密码不对,
但是空密码就可以进,
真是搞不懂!!
感谢回答者: 309366558
你说的方法我是知道的
我现在的问题是:
我使用的是免安装版的,并且我已经修改了配置文件而且设置了密码,
怎么就不管用呢???

修改登录密码

MySQL默认没有密码,安装完毕增加密码的重要性是不言而喻的。

1、命令
/usr/bin/mysqladmin -u root password 'new-password'
格式:mysqladmin -u用户名 -p旧密码 password 新密码

2、例子
例1:给root加个密码123456。
键入以下命令 :
[root@test1 local]# /usr/bin/mysqladmin -u root password 123456
注:因为开始时root没有密码,所以-p旧密码一项就可以省略了。

3、测试是否修改成功
1)不用密码登录
[root@test1 local]# mysql
ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)
显示错误,说明密码已经修改。
2)用修改后的密码登录
[root@test1 local]# mysql -u root -p
Enter password: (输入修改后的密码123456)
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 4.0.16-standard
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
成功!
这是通过mysqladmin命令修改口令,也可通过修改库来更改口令