mysql改密码遇到的一些问题

安装mysql server,要检验与Apache和PHP时,由上一篇的一些方法需要拥有密码,便设置了密码。

其中也出现了一些问题,很疑惑,其实都是小问题。但也浪费了很多时间。

一下两个网页有部分内容,有提点作用:

http://blog.csdn.net/inbyte/article/details/4254130

http://cache.baiducontent.com/c?m=9d78d513d99d1af31fa7837e7c499c275a0a97634d9687553b83d35f92144c30467195ca30531013a4b5682041f14606acb6746536703daacb96d51fcabbe57975d37b673740dd0b05d36ef39c0038867bc64de9d919e4b0f53991aed7c4df22089c44050c83f58d5b0311c178f0636ba5f9c7&p=ce769a4791934eac5fea882c585d92&newp=91759a46d1c401e034bbdb2d021480231610db2151d6d7123f9bff1edc&user=baidu&fm=sc&query=Linux+mysql+server%C3%DC%C2%EB&qid=&p1=1


1、我之前没有设置密码

命令 usr/bin/mysqladmin -u root password 'new-password' 
格式:mysqladmin -u用户名 -p旧密码 password 新密码 
例子 
例1:给root加个密码123456。 
键入以下命令 : 
# /usr/bin/mysqladmin -u root password 123456 
注:因为开始时root没有密码,所以-p旧密码一项就可以省略了。

测试是否修改成功 
1)不用密码登录 
# mysql 
ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO) 
显示错误,说明密码已经修改。 
2)用修改后的密码登录 
# 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> 
成功!

 

我把密码设为yxf

/usr/bin/mysqladmin -u root password yxf

但我登陆的时候出现问题。

没设置密码时可以直接登陆:

root@ubuntu:/usr/local/mysql# ./support-files/mysql.server start
Warning: World-writable config file '/usr/local/mysql/my.cnf' is ignored
Starting MySQL
... * 
root@ubuntu:/usr/local/mysql# ./bin/mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.19 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>


设置密码之后;

root@ubuntu:/usr/local/mysql/bin# ./mysql -u root -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

输入正确密码也没有用:

一直查资料,最后改为才行:

root@ubuntu:/usr/local/mysql# ./support-files/mysql.server restart
Shutting down MySQL
.. * 
Starting MySQL
. * 
root@ubuntu:/usr/local/mysql# ./bin/mysql -uroot -p 
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.19 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> 


原因没找到,过了一段时间./mysql -u root -p有可以了,真叫人纠结


//********************************************

mysql用户没设置密码,

 ./bin/mysql -u mysql 可进入

 ./bin/mysql -u root 不行

其他:

mysql> select host, user, password from mysql.user;
+-----------+------+-------------------------------------------+
| host      | user | password                                  |
+-----------+------+-------------------------------------------+
| localhost | root | *C5BF65EFBC5EE021DB884FAA5A4BDCB83CA726CF |
| ubuntu    | root |                                           |
| 127.0.0.1 | root |                                           |
| ::1          | root |                                           |
| localhost |      |                                           |
| ubuntu     |      |                                           |
+-----------+------+-------------------------------------------+
6 rows in set (0.02 sec)

上面的查询结果, 是  root@localhost   有密码。
其它用户t@localhost   , 都不要要输入密码的情况。

----自己的密码设置问题

/usr/bin/mysqladmin -u root password yxf

估计那时密码改为/usr/bin/mysqladmin -u mysql password yxf

就是mysql需要密码,root不需要

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值