查看数据库
1win+r然后输入cmd
2输入mysql -uroot -p
3输入你的密码
4输入 show databases;
5完成
MySQL密码忘记
1.以管理员身份运行cmd,关闭mysql服务
net stop mysql
2.跳过密码输入授权
mysqld --console --skip-grant-tables --shared-memory
3.再打开一个cmd窗口,重置密码
### 执行命令 : mysql(会直接进入不用输入密码)
### 执行命令 : use mysql(进入msql这个数据库)
### 查看一下数据 : select user,password,host from user;
此处报错:
ERROR 1054 (42S22): Unknown column 'password' in 'field list'
解决:
问题原因:password 字段是在mysql 8以下的版本中标记mysql数据库里 user表里的密码字段,但是mysql 8的密码字段改了,改成了:authentication_string
所以当环境变成mysql 8的时候 对应的sql语句应该变成:select user, authentication_string, host from user;
修改密码 :update user set authentication_string='123456' where user='root' and host='localhost';
报错:
ERROR 1054 (42S22): Unknown column 'password' in 'field list'
修改:update mysql.user set authentication_string=password('123456') where user='root' and Host ='localhost';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysql>update mysql.user set authentication_string=password('123456') where user=' at line 1
update user set authentication_string='123456' where user='root' and host='localhost';
成功!
4.关闭这两个cmd窗口,重新打开一个
启动服务 : net start mysql
进入mysql: mysql -uroot -p