MySQL 问题 总结
- MySQL 忘记密码解决方式(基于 deepin 15.8 系统[Linux])
- sudo gedit /etc/mysql/mysql.conf.d/mysqld.cnf
- 找到[mysqld] 在其正下方添加:skip-grant-tables 目的是跳过权限检查
- 重新启动 mysql: sudo mysql -u root -p 直接按空格进入数据库
- 修改密码:set password for ‘root’@‘localhost’=password(‘123456’);
- 返回原来的 mysqld.cnf 文件中删除 skip-grant-tables (这里强调一下不同系统的文件可能文件名不同一定要找到[mysqld] 可以使用 ctrl+F 快速查询)
- 重新使用: sudo mysql -u root -p 既可以重新进入数据库
2.完全卸载mysql
- sudo apt-get autoremove --purge mysql-server-5.7
- apt-get remove mysql-common
- 清除mysql-common配置:dpkg -l |grep ^rc|awk ‘{print $2}’ |sudo xargs dpkg -P
3.安装数据库
- sudo apt-get install mysql-server mysql-client
4.deepin安装mysql5.7无法使用root用户登录
- 使用sudo cat /etc/mysql/debian.cnf查看用户名和密码并用其登录
- 之后使用use mysql;命令选中mysql数据库
- 用命令update user set authentication_string=password(“这里填写自定义密码”) where user=“root”;更新user表
- 然后再使用update user set plugin=“mysql_native_password” where user="root"命令更新user表
- 使用flush privileges;命令
- 最后,退出,使用systemctl restart mysql.service命令重启mysql即可使用root用户登录。