具体的内容:
1. 检查mysql
服务是否启动,如果启动,关闭mysql
服务
运行命令:ps -ef | grep -i mysql
如果开着就运行关闭的命令:service my
sqld stop
2.修改mysql的配置文件my.conf
一般在/etc目录下,运行命令:vi /etc/my.cnf,编辑文件
在文件的[mysqld]标签下添加一句:
skip-grant-tables
.
然后wq!保存退出。
3.重启数据库
运行命令:service mysqld start
4.进入到mysql数据库
mysql -u root
5.修改密码
运行use mysql;
继续运行语句: update mysql.user set authentication_string=password('自己想设置的密码') where user='root';
6.把步骤2加的东西删除掉,在重启服务器,就可以使用刚才修改的密码登录进服务器了
mysql -u root -p