mysql的启动关闭原理和实战,及常见的错误排查

news2024/9/30 5:28:52

前言

MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,属于 Oracle 旗下产品。MySQL是最流行的关系型数据库管理系统之一,在 WEB 应用方面,MySQL是最好的 RDBMS (Relational Database Management System,关系数据库管理系统) 应用软件之一。

在这里插入图片描述

mysql的启动关闭原理和实战,及常见的错误排查

  • 一、生产中mysqlq启动方式
    • 1.1 mysql的启动原理
    • 1.2 参数文件的优先级
    • 1.3 以server的方式启动mysql(实际启动mysql方式)
    • 1.4 mysqld_safe方式启动
    • 1.5 mysqld方式启动
    • 1.6 systemctl方式启动(CentOS 7)
  • 二、关库
    • 2.1 相关参数innodb_fast_shutdown (数据库关闭参数)
    • 2.2 相关参数innodb_force_recovery(恢复参数)
    • 2.2 关闭mysql多种方式
  • 三、常见的mysql启动失败案例
    • 3.1 目录权限
    • 3.2 参数问题
    • 3.3 配置文件
    • 3.4 端口占用
    • 3.5 误删二进制文件
    • 3.6 undo表空间异常
    • 3.7 binlog缓冲异常
  • 四、mysql启动失败的排查方法
  • 五、连接mysql的方式
    • 5.1 本地连接
    • 5.2 远程连接
  • 六、mysql数据库用户安全策略
    • 6.1 数据库的初始化
    • 6.2 修改密码
    • 6.3 删除无用用户
    • 6.4 mysql_secure_installation
    • 6.5 找回丢失的用户密码

一、生产中mysqlq启动方式

在上一章节的时候,我们对mysql.server和mysqld_multi.server脚本做了修改,如果能修改到脚本初始化的状态可以自己修改,如果不可以就重新安装mysql。后面我们在修改配置文件的时候可以使用cp命令进行备份。

1.1 mysql的启动原理

在这里插入图片描述
脚本调用关系

service-->mysqld.safe-->mysqld-->启动mysql
systemctl-->mysqld-->启动mysql
mysqld.safe-->mysqld-->启动mysql
mysqld-->启动mysql

mysql.server会调用mysqld_safe,mysql_safe会调用mysqld

[root@mysql2 ~]# ll /usr/local/mysql/support-files/mysql.server 
-rwxr-xr-x. 1 7161 31415 10599 4月  15 09:10 /usr/local/mysql/support-files/mysql.server
/usr/local/mysql/support-files/mysql.server
[root@mysql2 ~]# cat /usr/local/mysql/support-files/mysql.server 

在这里插入图片描述
mysqld_safe

[root@mysql2 ~]# ll /usr/local/mysql/bin/mysqld_safe 
-rwxr-xr-x. 1 7161 31415 27862 6月   8 2022 /usr/local/mysql/bin/mysqld_safe
mysqld_safe的启动会同时启动mysqld,也会监控mysqld

mysqld

[root@mysql2 ~]# which mysqld
/usr/local/mysql/bin/mysqld
[root@mysql2 ~]# ll /usr/local/mysql/bin/mysqld
-rwxr-xr-x. 1 7161 31415 255653197 6月   8 2022 /usr/local/mysql/bin/mysqld

mysqld_multi:用来启动多实例的

1.2 参数文件的优先级

my.cnf可以看做是mysql的参数文件,和oracle一样可以存在多个地方。不同的是不指定参数文件的情况下,oracle启动的时候只会读取优先顺序第一的参数文件,而mysql则有点不同,会按照参数文件的等级来陆续读取。

上一章节的时候我们启动数据库需要指定参数文件,如果我们的参数文件在指定的位置,就不需要指定参数,使用如下命令查询mysql默认参数位置

[root@mysql2 ~]# mysqld --verbose --help | grep my.cnf
mysqld: Can't change dir to '/opt/mysql/mysql-5.7.39-linux-glibc2.12-x86_64/data/' (Errcode: 2 - No such file or directory)
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf 
                      my.cnf, $MYSQL_TCP_PORT, /etc/services, built-in default

优先级的高低顺序从右到左,读取顺序是从左到右。前面两个可以视为全局参数 , 后面两个可以视为用户选项参数。

也可以这么理解 ,4个参数同时存在的话,系统会按照优先等级来读取参数文件

  1. 先读取等级较低的/etc/my.cnf
  2. 接着读取/etc/mysql/my.cnf
  3. 接着读取–>/usr/local/mysql/etc/my.cnf
  4. 最后读取~/.my.cnf参数文件

最后只能应用~/.my.cnf参数文件里的所有参数。

如果这几个目录里都没有参数文件,在安装,启动,停止的时候需要我们手动指定参数文件。如下:

[root@mysql2 ~]#nohup mysqld --defaults-file=/data/mysql/my3306/my3306.cnf  &

1.3 以server的方式启动mysql(实际启动mysql方式)

首先我们先对server进行备份,在将server文件移到 /etc/init.d目录下面,成为一个常规的服务文件

[root@mysql2 ~]# cp /usr/local/mysql/support-files/mysql.server /usr/local/mysql/support-files/mysql.server.bak
[root@mysql2 ~]# cp -f /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
cp:是否覆盖"/etc/init.d/mysqld"? y

接着将mysql参数文件移到 /etc 目录下,作为mysql的全局参数文件

[root@mysql2 ~]# cp /data/mysql/my3306/my3306.cnf /etc/my.cnf
cp:是否覆盖"/etc/init.d/mysqld"? y

通过服务器启动mysql

[root@mysql2 ~]# /etc/init.d/mysqld start
Starting MySQL SUCCESS! 
[root@mysql2 ~]# 2023-04-15T02:40:43.366648Z mysqld_safe A mysqld process already exists
[root@mysql2 ~]# lsof -i:3306
COMMAND   PID  USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
mysqld  13462 mysql   32u  IPv6 1611543      0t0  TCP *:mysql (LISTEN)
[root@mysql2 ~]# ps -ef | grep mysql

在这里插入图片描述

添加到mysqld到service

[root@mysql2 ~]# chkconfig --add /etc/init.d/mysqld
[root@mysql2 ~]# chkconfig --list mysqld

注:该输出结果只显示 SysV 服务,并不包含
原生 systemd 服务。SysV 配置数据
可能被原生 systemd 配置覆盖。 

      要列出 systemd 服务,请执行 'systemctl list-unit-files'。
      查看在具体 target 启用的服务请执行
      'systemctl list-dependencies [target]'。

mysqld         	0:关	1:关	2:开	3:开	4:开	5:开	6:关

1.4 mysqld_safe方式启动

启动命令:nohup mysqld_safe --defaults-file=/data/mysql/my3306/my3306.cnf

如果参数文件在默认位置,就可以不用指定

[root@mysql2 ~]# nohup mysqld_safe &
[1] 15524
[root@mysql2 ~]# lsof -i:3306
COMMAND   PID  USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
mysqld  15953 mysql   31u  IPv6 1647497      0t0  TCP *:mysql (LISTEN)
[root@mysql2 ~]# ps -ef | grep mysql

在这里插入图片描述

1.5 mysqld方式启动

启动命令:nohup mysql --defaults-file=/data/mysql/my3307/my3307.cnf

如果参数文件在默认位置,就可以不用指定

[root@mysql2 ~]# nohup mysqld &
[1] 16985
[roott@mysql2 ~]# lsof -i:3306
COMMAND   PID  USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
mysqld  16985 mysql   31u  IPv6 1611742      0t0  TCP *:mysql (LISTEN)
[root@mysql2 ~]# ps -ef | grep mysql

在这里插入图片描述

1.6 systemctl方式启动(CentOS 7)

[root@mysql2 ~]# cat <<EOF>> /etc/systemd/system/my3306.service
[Unit]
Description=MySQL Server by
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/usr/local/mysql/bin/mysqld ##--defaults-file=/data/mysql/my3306/my3306.cnf
LimitNOFILE = 5000
EOF
[root@mysql2 ~]# more /etc/systemd/system/my3306.service 
[root@mysql2 ~]# systemctl start my3306.service 
[root@mysql2 ~]# systemctl status my3306.service 
● my3306.service - MySQL Server by
   Loaded: loaded (/etc/systemd/system/my3306.service; disabled; vendor preset: disabled)
   Active: active (running) since 六 2023-04-15 11:11:46 CST; 7s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
 Main PID: 17671 (mysqld)
    Tasks: 27
   CGroup: /system.slice/my3306.service
           └─17671 /usr/local/mysql/bin/mysqld

4月 15 11:11:46 mysql2.x88.com systemd[1]: Started MySQL Server by.
[root@mysql2 ~]# lsof -i:3306
COMMAND   PID  USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
mysqld  17671 mysql   31u  IPv6 1629942      0t0  TCP *:mysql (LISTEN)

常用命令 start status stop enable disanble

二、关库

2.1 相关参数innodb_fast_shutdown (数据库关闭参数)

[root@mysql2 my3306]# mysql -uroot -p --socket=/data/mysql/my3306/mysql.sock
mysql> select @@innodb_fast_shutdown ;
+------------------------+
| @@innodb_fast_shutdown |
+------------------------+
|                      1 |
+------------------------+
1 row in set (0.00 sec)

在关闭时,参数innodb_fast_shutdown影响着表的存储引擎为InnoDB的行为。该参数可取值为0、1、2,默认值为1

  • 0表示在MySQL数据库关闭时,InnoDB需要完成所有的full purge(回收页)和merge insert buffer(合并插入缓冲区),并且将所有的脏页刷新回磁盘。这需要一些时间,有时甚至需要几个小时来完成。如果在进行InnoDB升级时,必须将这个参数调为0,然后再关闭数据库。
  • 1是参数innodb_fast_shutdown的默认值,表示不需要完成上述的full purge和merge insert buffer操作,但是在缓冲池中的一些数据脏页还是会刷新回磁盘。生产环境推荐的参数
  • 2表示不完成full purge和merge insert buffer操作,也不将缓冲池中的数据脏页写回磁盘,而是将日志都写入日志文件。这样不会有任何事务的丢失,但是下次mysql数据库启动时,会进行恢复操作(recovery)。如果写入日志文件出现异常,可能导致数据启动不了。

2.2 相关参数innodb_force_recovery(恢复参数)

mysql> select @@innodb_force_recovery ;
+-------------------------+
| @@innodb_force_recovery |
+-------------------------+
|                       0 |
+-------------------------+
1 row in set (0.00 sec)

当正常关闭mysql数据库时,下次的启动应该是非常“正常”。但是如果没有正常地关闭数据库,如用kill命令关闭数据库,在mysql数据库运行中重启了服务器,或者在关闭数据库时,将参数innodb_fast_shutdown设为2,下次mysql数据库启动时都会对InnoDB存储引擎的表进行恢复操作.

参数innodb_force_recovery影响了整个InnoDB存储引擎恢复的状况。该参数值默认为0,代表当发生需要恢复时,进行所有的恢复操作,当不能进行有效恢复时,如数据页发生了corruption(坏块),mysqL数据库可能发生宕机(crash),并把错误写入错误日志中去。
但是,在某些情况下,可能并不需要进行完整的恢复操作,比如在对一个表进行alter table操作时发生意外了,数据库重启时会对InnoDB表进行回滚操作,对于一个大表来说这需要很长时间,可能是几个小时。这时用户可以自行进行恢复,例如把表删除,从备份中重新导入数据到表,可能这些操作的速度要远远快于回滚操作。

参数innodb_force_recovery还可以设置为6个非零值:1到6。大的数字表示包含了前面所有小数字表示的影响。具体情况如下:

  • 1(SRV_FORCE_IGNORE_CORRUPT):忽略检查到的corrupt页。
  • 2(SRV_FORCE_NO_BACKGROUND):阻止Master Thread线程的运行,如MasterThread线程需要进行full purge(完整清理)操作,而这会导致crash。
  • 3(SRV_FORCE_NO_TRX_UNDO):不进行事务的回滚操作。
  • 4(SRV_FORCE_NO_IBUF_MERGE):不进行插入缓冲的合并操作。
  • 5(SRV_FORCE_NO_UNDO_LOG_SCAN):不查看撤销日志(Undo Log),InnoDB存储引擎会将未提交的事务视为已提交。
  • 6(SRV_FORCE_NO_LOG_REDO):不进行前滚的操作。

建议:生产环境只能设置为0。即遇到故障,系统就要自动进行所有恢复操作。如果启动不了,就调整该参数进行数据库的调整。

2.2 关闭mysql多种方式

关闭脚本方法说明
/etc/init.d/mysqld stop使用stop参数调用时关闭本地服务器
mysqladmin -uroot -p123456 shutdown作为客户机连接到服务器并且关闭服务器
mysql> shutdown;作为客户机连接到服务器并且关闭服务器(有管理员(root)的权限)
kill -9 pid杀掉mysqld进程,不建议使用

三、常见的mysql启动失败案例

3.1 目录权限

目录权限问题导致MySQL启动失败

[ERROR] Could not open file '/data/mysql/my3306/logs/error.log'  for error logging: Permission denied

原因:数据目录的用户和用户组不是我们设置的用户

解决:

[root@mysql2 ~]# chown -R mysql:mysql /data/*
[root@mysql2 ~]# chmod -R 750 /data/mysql/

3.2 参数问题

在修改配置文件参数时,可能因为参数拼写错误或者参数因版本不再支持,在错误日志会记录内容,在mysql启动关闭及在运行时的错误

[ERROR] unknown variable 'basedi=/usr/local/mysql'

解决:在配置文件将错误的参数修改

3.3 配置文件

在启动时,mysqld 如果默认位置没有my.cnf,则要通过–defaults-file指定正确的配置文件

[root@mysql2 ~]# mysqld --verbose --help |grep defaults
--print-defaults        Print the program argument list and exit.
--no-defaults           Don't read default options from any option file,
--defaults-file=#       Only read default options from the given file #.
--defaults-extra-file=# Read this file after the global files are read.
--defaults-group-suffix=#
--explicit-defaults-for-timestamp 
                      Dump only the hottest N% of each buffer pool, defaults to
explicit-defaults-for-timestamp                              FALSE
[root@mysql2 ~]# nohup mysqld_safe --defaults-file=/data/mysql/my3306/my3306.cnf

3.4 端口占用

端口被占用导致MySQL启动失败

[ERROR] Do you already have another mysqld server running on port: 3306 ?

在多实例的环境下,因为某几个实例的端口是一样的,导致启动时造成端口的冲突,而无法启动,我们需要修改端口

3.5 误删二进制文件

二进制日志文件保的记录已提交的dml、ddl、dcl,主要用来主从复制、增量备份,而我们手工删除二进制文件导致mysql启动失败

[ERROR] Failed to open log (file '/data/mysql/my3306/logs/mysql-bin.000012', errno 2)

解决:vim mysql-bin.index 将对应的二进制日志文件记录删除即可

3.6 undo表空间异常

修改共享表空间参数大小导致MySQL启动失败,而共享表空间:ibdata1里保存元数据信息、insert buffer、double write、undo、回滚指针

参数:innodb_data_file_path=ibdata1:12M:autoextend

[ERROR] InnoDB: The Auto-extending innodb_system data file './ibdata1' is of a different size 768 pages (rounded down to MB) than specified in the .cnf file: initial 8192 pages, max 0 (relevant if non-zero) pages!

解决:在初始化数据库之前设置innodb_data_file_path的大小。重新修改配置文件中innodb_data_file_path的大小,必须是小于默认的大小(12M)或者等于默认的大小

3.7 binlog缓冲异常

报错

mysql> call insert_emp(1,4000000);

ERROR 1534 (HY000): Writing one row to the row-based binary log failed

+---------------------+
| @@binlog_cache_size |
+---------------------+
| 2097152 			  |
+---------------------+

1 row in set (0.00 sec)

因为内存不足导致的binlog cache size不够不能写入binlog,导致语句无法执行 在配置文件中调整binlog_cache_size和max_binlog_cache_size参数的值,改大一点

binlog_cache_size = 128M(binlog缓存根据实际情况调大)
max_binlog_cache_size = 512M (binlog日志根据实际情况调大)

四、mysql启动失败的排查方法

首选我们需要明确当前的数据库版本,启动方式和配置文件等,查看错误日志文件

mysql> select @@log_error;
+-----------------------------------+
| @@log_error                       |
+-----------------------------------+
| /data/mysql/my3306/logs/error.log |
+-----------------------------------+
1 row in set (0.01 sec)
mysql> show variables like '%log_error%';
+---------------------+-----------------------------------+
| Variable_name       | Value                             |
+---------------------+-----------------------------------+
| binlog_error_action | ABORT_SERVER                      |
| log_error           | /data/mysql/my3306/logs/error.log |
| log_error_verbosity | 3                                 |
+---------------------+-----------------------------------+
3 rows in set (0.00 sec)

五、连接mysql的方式

5.1 本地连接

[root@mysql2 ~]# mysql -uroot -p123456 --socket=/data/mysql/my3306/mysql.sock

如果不想指定套接字文件,我们可以使用软连接到默认的指定位置

[root@mysql2 ~]# ln -sf /data/mysql/my3306/mysql.sock /tmp/mysql.sock
[root@mysql2 ~]# mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.39-log MySQL Community Server (GPL)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

5.2 远程连接

  • -u 用户名
  • -p 密码
  • -P 端口
  • -h 远程地址
[root@mysql1 ~]# mysql -uroot -pCjlr2023! -P3306 -h10.30.0.60
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.7.39-log MySQL Community Server (GPL)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

六、mysql数据库用户安全策略

6.1 数据库的初始化

方式一: –initialize-insecure 默认管理员root,密码为空
如果mysql参数文件在默认位置,可以忽略

[root@mysql1 ~]# mysqld --defaults-file=/data/mysql/my3306/my3306.cnf --initialize-insecure --user=mysql

mysql登陆

-S 参数 = --socket=/data/mysql/my3306/mysql.sock,如果套接字文件在默认位置,可以忽略

[root@mysql1 ~]# mysql -uroot -S /data/mysql/my3306/mysql.sock 

方式二(推荐使用): –initialize 默认管理员root,生成密码;保存在error.log
如果mysql参数文件在默认位置,可以忽略

[root@mysql1 ~]# mysqld --defaults-file=/data/mysql/mysql3306/my3306.cnf --initialize --user=mysql --basedir=/usr/local/mysql  --datadir=/data/mysql/mysql3306/data

6.2 修改密码

方法一:登陆数据库,修改密码

[root@mysql1 ~]# mysql -uroot -pCjlr2023! -P3306 -h10.30.0.60
mysql> alter user root@'%' identified by '123456';
mysql> flush privileges;

方法二:mysqladmin修改密码

[root@mysql2 ~]# mysqladmin -uroot -p password
Enter password: 
New password: 
Confirm new password: 
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.

6.3 删除无用用户

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select user from user;
+---------------+
| user          |
+---------------+
| root          |
| mysql.session |
| mysql.sys     |
| root          |
+---------------+
4 rows in set (0.00 sec)

mysql> delete from user where user !='root';
Query OK, 2 rows affected (0.01 sec)

mysql> select user from user;
+------+
| user |
+------+
| root |
| root |
+------+
2 rows in set (0.00 sec)

mysql> grant all privileges on *.*  to  'multis'@'%'  identified by '123456'  with grant option;
mysql> grant all privileges on *.*  to  'multis'@'localhost'  identified by '123456'  with grant option;

mysql> flush privileges;

6.4 mysql_secure_installation

用于安装后,权限安全的初始化

[root@mysql2 ~]#  mysql_secure_installation -uroot -p --socket=/data/mysql/my3306/mysql.sock
#输入日志里密码
Enter password:  

Securing the MySQL server deployment.


The existing password for the user account root has expired. Please set a new password.
#设置新密码
New password: 
#确认新密码
Re-enter new password: 

#是否设置验证密码插件
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: 
Using existing password for root.
Change the password for root ? ((Press y|Y for Yes, any other key for No) : 

 ... skipping.
 # 是否删除匿名账户
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : 

 ... skipping.

# 是否禁止远程登录root用户
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : 

 ... skipping.
 # 是否删除test 数据库
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : 

 ... skipping.
# 是否重新加载特权表
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : 

 ... skipping.
All done!

6.5 找回丢失的用户密码

方式一: 管理员root密码丢失,无法登录数据库,我们关闭数据后可以在参数文件中添加skip-grant-tables参数

[root@mysql2 ~]# cat /etc/my.cnf 
[mysqld]
user=mysql
basedir=/usr/local/mysql
datadir=/data/mysql/my3306/data
socket = /data/mysql/my3306/mysql.sock
server_id = 1
port = 3306
log_error=/data/mysql/my3306/logs/error.log
log_bin=/data/mysql/my3306/logs/mysql-bin
binlog_format=row
gtid_mode=on
enforce_gtid_consistency=true
log_slave_updates=1
max_connections=1024
wait_timeout=60
sort_buffer_size=2M
max_allowed_packet=32M
join_buffer_size=2M
innodb_buffer_pool_size=128M
innodb_flush_log_at_trx_commit=1
innodb_log_buffer_size=32M
innodb_log_file_size=128M
innodb_log_files_in_group=2
binlog_cache_size=2M
max_binlog_cache_size=8M
max_binlog_size=512M
expire_logs_days=7
slow_query_log=on
slow_query_log_file=/data/mysql/my3306/logs/slow.log
long_query_time=0.5
log_queries_not_using_indexes=1
skip-grant-tables

[root@mysql2 ~]# mysqld &
[root@mysql2 ~]# mysql
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> alter user root@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

密码修改完成,关闭数据库。注释到skip-grant-tables参数


mysql> shutdown;
Query OK, 0 rows affected (0.00 sec)

在这里插入图片描述

启动数据库

[root@mysql2 ~]# mysqld &

方式二 :

[root@mysql2 ~]# mysqld --skip-grant-tables &
[root@mysql2 ~]# mysql
mysql> flush privileges;
mysql> alter user root@'localhost' identified by '123456';
mysql> flush privileges;
mysql> shutdown;
mysql> exit;
[root@mysql2 ~]# nohup mysqld &
[root@mysql2 ~]# mysqld -uroot -p

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/438082.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【数据结构】顺序表和链表(上)(附leetcode练习题)

☃️个人主页&#xff1a;fighting小泽 &#x1f338;作者简介&#xff1a;目前正在学习C语言和数据结构 &#x1f33c;博客专栏&#xff1a;数据结构 &#x1f3f5;️欢迎关注&#xff1a;评论&#x1f44a;&#x1f3fb;点赞&#x1f44d;&#x1f3fb;留言&#x1f4aa;&…

春秋云境:CVE-2022-30887(文件上传漏洞)

目录 一.题目 二.蚁剑方式 三.POC方式 一.题目 该CMS中php_action/editProductImage.php存在任意文件上传漏洞&#xff0c;进而导致任意代码执行。 进入页面&#xff1a;登录页面 随意输入用户名和密码&#xff1a;admingmail.com admin 用于burp抓包&#xff1a; burp抓包…

基于PCL抓取Velodyne激光雷达数据包可视化

Velodyne 高清激光雷达 (HDL) 采集器 Velodyne HDL 是一种基于网络的 3D LiDAR 系统&#xff0c;每秒生成包含超过 700,000 个点的 360 度点云。 PCL 中提供的 HDL Grabber 模仿其他 Grabbers&#xff0c;使其几乎可以即插即用。 然而&#xff0c;由于 HDL 设备是基于网络的&…

线性表总结

线性表 目录&#xff1a; 文章目录 线性表概念一、线性表的定义二、线性表的基本操作三、线性表的实现方式四、线性表的应用总结 概念 线性表是一种基本的数据结构&#xff0c;由一系列具有相同类型的数据元素构成&#xff0c;这些元素之间具有线性的顺序关系&#xff0c;每个…

python+vue+django旅游景点酒店线路套餐管理系统

1.查询旅游信息:主要查询景点和酒店的信息&#xff0c;可以进行分类查询也可以用关键在字来查询用户需要的信息。 2.留言功能:用户可以查看别人以前的留言&#xff0c;也可以发表新的留言。. 3.酒店预定:当用户查询到相关酒店&#xff0c;并且可以能够申请相关酒店预定。 4.信息…

【人工智能】— 一阶逻辑、量词的推理规则、一般化分离规则、合一、前向/反向链接算法、归结算法

这里写自定义目录标题 量词的推理规则全称量词实例化存在量词实例化 简化到命题逻辑推理Generalized Modus Ponens&#xff08;一般化分离规则&#xff09;举例 合一Forward chaining 前向链接算法示例 Backward chaining algorithm 反向链接算法一般FOL的FC/BC的完整性 归结算…

系统分析师选择题笔记

目录 1、知识产权与标准化 1.1 保护范围与对象(★★★★) 1.2 保护期限(★) 1.3 知识产权人确定(★★★) 1.4 侵权判断(★★★) 1.5 标准的分类(★) 1.6 标准代号的识别(★) 2、系统配置与性能评价 2.1 系统性能概述 2.2 系统性能&#xff08;性能指标&#xff09;(★…

8款数据迁移工具选型,主流且实用

前言&#xff1a;ETL(是Extract-Transform-Load的缩写&#xff0c;即数据抽取、转换、装载的过程)&#xff0c;对于企业应用来说&#xff0c;我们经常会遇到各种数据的处理、转换、迁移的场景。今天特地给大家汇总了一些目前市面上比较常用的ETL数据迁移工具&#xff0c;希望对…

什么是B/S架构?

目录 一.什么是B/S架构&#xff1f; 二.B/S架构与C/S架构有什么区别&#xff1f; 三.B/S架构的优缺点 四.B/S架构的几种形式 1&#xff1a;客户端-服务器-数据库 2&#xff1a;客户端&#xff0d;web服务器&#xff0d;应用服务器&#xff0d;数据库 3&#xff1a;客户端…

4个方法助你从戴尔笔记本电脑D盘中恢复丢失的文件

用户案例&#xff1a; 案例1&#xff1a;我有一台戴尔笔记本电脑&#xff0c;D盘上存储了很多个人照片和视频&#xff0c;但最近不知道什么原因&#xff0c;这些数据突然全部消失了。因为这些数据是我珍贵的回忆。所以想问问大家戴尔电脑丢失d盘文件怎么恢复&#xff1f; 案例2…

网络中的网关和物联网的网关区别 局域网 路由器 交换机 服务器

网关&#xff1a;是个概念。连接两种不同的网络。例如局域网要与外部通信&#xff0c;需要经过网关。 设备和设备之间的通信&#xff0c;转换协议需要网关 路由器里有功能是对网关这个概念的实现。 所以网关它可以是路由器&#xff0c;交换机或者是PC。 路由器有网关功能&a…

Flink-Scala版学习——转换算子

目录 一、基本转换算子 1.map 2.filter 3.flatMap 3.聚合算子Aggregation (1)keyBy (2)简单聚合&#xff1a;sum、min、minBy、max、maxBy (3)归约聚合&#xff1a;reduce 二、UDF 三、富函数类 四、物理分区 1.随机分区(shuffle) 2. 轮询分区&#xff08;Round-R…

4月20日第壹简报,星期四,农历三月初一,谷雨

4月20日第壹简报&#xff0c;星期四&#xff0c;农历三月初一&#xff0c;谷雨坚持阅读&#xff0c;静待花开1. 已致29人死亡&#xff0c;26人为患者&#xff01;北京长峰医院火灾事故因院内施工作业火花引发&#xff0c;院长王某玲等12人被刑拘。2. 海南发布旅游产品参考价格&…

第二十三章 案例TodoList之数据更新

本小节&#xff0c;我们要实现点击复选框&#xff0c;修改任务项的实时状态&#xff0c;但是Item组件和App组件是祖孙关系&#xff0c;不是父子关系&#xff0c;我们还能使用props进行通信吗&#xff1f;答案是可以的。 在App组件定义一个更新的函数并传递给Item组件 1、定义…

车载网络 - Autosar网络管理 - 网络管理报文

三、网络管理报文 NM报文的ID一般定义为&#xff1a;基础ID源地址&#xff0c;每个节点应分配一个唯一的标识符&#xff08;ECU地址&#xff09;Node_ID&#xff0c;网络管理报文一般会统一一个基地址&#xff0c;这个是根据主机厂不同而不同&#xff0c;有些是用0x400 - 0x4FF…

多通道振弦传感器无线采集仪如何外接数字传感器

多通道振弦传感器无线采集仪如何外接数字传感器 数字传感器的数据接入逻辑 VS 设备支持在 RS485 接口外接数字传感器&#xff0c; 可进行单类型、多类型数字传感器接入。 单类型数字传感器&#xff1a;使用寄存器 DS_SENSOR(282)来设置单类型数字传感器的类型和数量&#xff08…

用Flutter开发一款企业级App(开眼Flutter-OpenEye)

先贴项目地址&#xff1a;WinWang/open_eye: Flutter 开眼APP&#xff1a;整体项目架构基于Getx搭建&#xff0c;完成路由&#xff0c;依赖注入&#xff1b;网络请求框架基于RetrofitDio实现&#xff0c;配合官方JsonSerialize实现解析&#xff1b;封装项目页面多状态&#xff…

新媒体运营团队如何协同工作?

随着媒体形式的不断丰富和演变&#xff0c;社交、短视频等软件的盛行&#xff0c;新媒体运营成为近几年新兴的行业。 在新媒体团队工作过程中可能会遇到以下问题&#xff1a; 1&#xff09;热点不断更迭&#xff0c;文档资料需要快速流通&#xff1b; 2&#xff09;通过传统的…

US-DAPQ比例放大器指令接线

序号 端子名称 功能 1 CMD_P 压力阀指令 2 CMD_P- 压力阀指令- 3 CMD_Q 流量阀指令 4 CMD_Q- 流量阀指令- 5/6 N.C. 不接 7 VREF_5V 参考电压5V 8 VREF_0V 参考电压0V 9 SOL_P 压力阀线圈 10 SOL_P- 压力阀线圈 11 PWR 电源 12 PWR- 电源- 13 SOL_Q- 流量阀线圈 1…

mysql知识

1.执行步骤 2.Write-Ahead Logging 技术 这两种日志有以下三点不同。 ①redo log 是 InnoDB 引擎特有的&#xff1b;binlog 是 MySQL 的 Server 层实现的&#xff0c;所有引擎都可以使用。 ②redo log 是物理日志&#xff0c;记录的是“在某个数据页上做了什么修改”&#x…