因为是系统自带的MYSQL,路径有点怪,我也是通过find才找到的,汗!
/usr/bin/mySQLadmin -u root -p oldpassword newpasswd
可是出现了下面的错误:
引用内容
./mySQLadmin: connect to Server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
出现这样的问题,那么说明MySQL是正常启动了,可是为什么出现这个错误提示呢?
于是先停止掉MySQL,换个模式启动:
引用内容
/usr/bin/mysqld_safe --user=mySQL --skip-grant-tables --skip-networking &
大概来说说这个启动mySQL的命令参数吧。
--skip-grant-tables :grant-tables,授权表。在启动mySQL时不启动这个表,像忘了密码啥的,用这个模式启动很方便的。
--skip-networking :不监听3306,说白了就是不启动mySQL的网络服务。
--user=mySQL :这俺就不形容了。
再试试直接登陆MySQL:
引用内容
mysql -u root mySQL
然后就可以来我们的修改密码大计啦:
引用内容
mySQL> Update user SET Password=PASSWORD('111111') where USER='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mySQL> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mySQL> quit;
Bye
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mySQL> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mySQL> quit;
Bye
如果已添加了MySQL为系统服务:
引用内容
[root@localhost /]# service mySQLd restart
大功告成了,别忘了iptables 去打开3306端口,呵呵。


