标签:
先停止mysql服务
/etc/init.d/mysqld stop
以安全模式启动mysql
/usr/local/mysql/bin/mysqld_safe --skip-grant-tables --skip-networking &
/usr/local/mysql/bin/mysql
UPDATE user SET password=password(‘12345‘) WHERE user=‘root‘;
flush privileges;
授权
grant all privileges on *.* to root@‘localhost‘ identified by ‘123456‘;
flush privileges;
有个地方要注意,/usr/local/mysql/bin/mysqld_safe 方式启动的时侯默认是读取/usr/local/mysql/data下的数据,如果你的data数据放在别的目录就会出现密码错误而被拒绝登陆的错误,
可以做个链接解决,(实际data目录的地址/opt/mysql/data) ln -s /opt/mysql/data /usr/local/mysql/
标签:
原文地址:http://www.cnblogs.com/latma/p/4178358.html