单用户
Linux 单用户
1. 没有远程网络, 只能本地登录
2. 没有验证功能 (PAM验证模块关闭)
MySQL 单用户
1. 关闭远程网络, 关闭TCP/IP连接协议, 只留socket方式
—skip-networking
2. 关闭验证功能, 不加载授权表, 不验证
—skip-grant-tables
处理办法
1. 数据库正常关闭/etc/init.d/mysqld stop2. 启动到 "单用户" 模式mysqld_safe --skip-networking --skip-grant-tables &或者:service mysqld start --skip-networking --skip-grant-tables#systemctl 不支持此操作3. 无密码登录MySQLmysql> alter user root@'localhost' identified by 'password';ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement#这个报错因为我们使用了 --skip-grant-tables 不加载授权表, 更改失败, 需要手动加载授权表mysql> flush privileges;mysql> alter user root@'localhost' identified by 'password';4. 重启数据库到正常模式/etc/init.d/mysqld restart
方式二: 配置文件
[mysqld]
skip-networking
skip-grant-tables
