Mysql:初始化目录文件介绍,修改管理员密码,忘记管理员密码(二)
1、系统初始化之后:
- [[email protected] data]# cd /data/mysql/data --系统初始化文件目录
- 系统执行初始化之后,在目录下会生成这些文件,这些文件是保证mysql能够正常启动的文件
- localhost.localdomain.err:msyql日志文件,msyql启动不了,可常看相应的日志记录
2、修改管理员密码:(msyql自带的本地管理员:[email protected])
****需要先启动mysql
- [[email protected] data]# mysqladmin -uroot -p password 456789 --这里输入的是新密码
- Enter password: --这里输入的老密码
3、管理员忘记密码,修改密码
- 修改过程遇到的问题记录到了:问题2:mysqld_safe 遇到的问题
- [[email protected] data]# msyqld_safe --skip-grant-tables --skip-networking &
- --skip-grant-tables #跳过授权表
- --skip-networking #跳过远程登录
- [[email protected] data]# msyql #不需要密码直接登录msyql,只能本地服务器登录,不能远程登录
- mysql> select user,host from mysql.user; #msyql的用户表
- mysql> desc mysql; #查看表结构,存储密码的字段
- mysql> select user,host,authentication_string from mysql.user; #加密后的密码
- mysql> alter user [email protected]'localhost' identified by '1'; #进行密码修改,有以下报错是因为,你已经把授权表关闭了,无法执行;
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement - mysql> flush privileges; #这一步操作相当于手动把授权表加载到内存中;
Query OK, 0 rows affected (0.00 sec) - mysql> alter user [email protected]'localhost' identified by '456789'; #在次执行修改root密码语句,提示修改成功// 也可以使用:grant on all *.* to [email protected]'localhost' identified by '456789';
- 再次查看mysql.user表;#密码发生变化
- 关闭msyqld_safe:mysqld_safe模式关闭不掉,想要关掉就需要杀掉进程,
- [[email protected] ~]# /etc/init.d/mysqld restart #重启下mysql,就会退出msyqld_safe 模式;msyql正常启动
- [[email protected] ~]# mysql -uroot -p #输入密码,即可进入mysql,密码修改成功
Enter password: