hopeless-dream

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

MySQL8.0启动和关闭流程

启动方式

1、 mysqld_safe &(推荐):这个脚本会监控mysqld的状态,日志会记录到文件里

2、 mysqld &                           日志打印到屏幕上

3、 mysql.server

调用的执行过程:systemd ------>/etc/init.d/mysqld-------->mysql.server------>mysqld_safe &----->mysqld &

关闭方式

mysql> shutdown;

systemctl stop mysqld

service mysqld stop

mysqladmin -uroot -p123456 shutdown

忘记管理员密码

1、关闭数据库

[root@localhost ~]# /etc/init.d/mysqld stop

Shutting down MySQL... SUCCESS!

2、启动安全模式

[root@localhost ~]# mysqld_safe --skip-grant-tables --skip-networking &

[1] 1475

[root@localhost ~]# 2020-01-18T14:07:12.861565Z mysqld_safe Logging to '/data/mysql/data_3306/localhost.err'.

2020-01-18T14:07:12.898677Z mysqld_safe Starting mysqld daemon with databases from /data/mysql/data_3306

3、登录数据库,修改密码,报错:没有加载授权表

[root@localhost ~]# mysql -uroot -p123

mysql> alter user root@'localhost' identified by '123456';

ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

4、手工加载授权表

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> alter user root@'localhost' identified by '123456';

Query OK, 0 rows affected (0.00 sec)

5、重启数据库

[root@localhost ~]# /etc/init.d/mysqld restart

Shutting down MySQL...2020-01-18T15:09:46.575313Z mysqld_safe mysqld from pid file /data/mysql/data_3306/localhost.pid ended

 SUCCESS!

3、 测试密码

[root@localhost ~]# mysql -uroot -p123456

mysql>

 

posted on   hopeless-dream  阅读(11231)  评论(0编辑  收藏  举报

编辑推荐:
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~
点击右上角即可分享
微信分享提示