5.7mysql安装问题

半城伤御伤魂 提交于 2020-02-20 02:55:50

5.7mysql安装问题

1.mysql安装了,查看是运行状态,无法停止,无法重启

安装命令:

查看mysql的进程:

​ ps -e|grep mysql

杀死mysql的进程:

​ sudo killall mysqld

查看mysql的状态:

​ service mysqld status

查看某个目录的占用内存情况:

​ du -ah --max-depth=1

操作mysql:

​ systemctl start mysqld.service 启动
​ systemctl stop mysqld.service 停止
​ systemctl restart mysqld.service 重启

​ etc/my.cnf mysql配置文件

mysql忘记密码的操作:

一、首先更改my.cnf的配置文件,并重启mysql

在my.cnf文件中的[mysqld] 下加入下面一行,其余不做改变。

[root@localhost ~]# vim /etc/my.cnf
[mysqld]
skip-grant-tables
[root@localhost ~]# systemctl restart mysqld

二、登录MySQL,此时不需要输入密码,直接回车即可

mysql -uroot -p

三、切换到mysql数据库,查询user表的结构,这里有需要的字段。

在MySQL5.7版本中mysql数据库下已经没有password这个字段了,password字段改成了authentication_string字段。

四、修改mysql的root密码并退出mysql

mysql> update user set authentication_string=password('djb123.') where user='root';
Query OK, 0 rows affected, 1 warning (0.00 sec)
Rows matched: 0  Changed: 0  Warnings: 1

mysql> \q
Bye

​ 五、再次修改my.cnf配置文件,将第一步添加的语句注释或删除,然后重启mysql。

[root@localhost ~]# vim /etc/my.cnf
[mysqld]
#skip-grant-tables
[root@localhost ~]# systemctl restart mysqld

六、用新密码登录mysql

修改mysql可以远程连接:
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!