mysql 客户端密码管理
MySQL数据库系统也是典型的C/S(客户端/服务器)架构的应用,连接时需要专用的客户端工具,Linux下通过mysql命令工具(如果是通过rpm格式安装软件需要安装mysql软件包)。
1: 连接并登录到MySQL操作环境
Mysql
-u 指定用户名
-p 指定密码(选项和密码之间不能有空格)
-h 指定主机
-P 指定端口
-S 指定socket文件
-e 指定SQL命令语句(非交互模式)
(1):mysql -uroot -p123456 -e 'select user();' 3非交互式访问(登录数据库)
(2):select user(); #查看当前连接用户
(3):status; #查看数据库状态
(4):exit 或者 /q 即可退出
2:mysql破解root管理员密码
(1):mysql -uroot -p123456; history -c #在history 中不显示
(2):systemctl stop mysqld #停掉数据库;注:(必须在低峰期停止)
(3): netstat -lnpt |grep :3306 #查看端口
(4): ps aux |grep mysql #查看进程
(5):mysqld_safe --skip-grant-tables & #启动
(6):mysql #登录即可(其登录不需要密码验证)
(7):select user,authentication_string from mysql.user where user='root'; #查询us
(8):uqdate mysql.user set authentication_string=password('123abc') where usr='root'; #替换上面的密码
以上及说明操作成功
(9):select user,authentication_string from mysql.user where user='root'; #查询
(10):exit 退出即可
(11):ps aux | grep mysql #查看进程
(12):kill -9 #杀死相关进程
(13): systemctl restart mysqld #重启服务即可(此时密码已经是自己的)
(14):mysql -u root -p123abc