You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
YltProject/操作文档/7、Mysql数据库下载与还原.md

163 lines
3.6 KiB

12 months ago
## 云数据库 RDS
12 months ago
4.07GB
5.7
hins25487844_data_20240730052418_qp.xb
还原办法:
https://www.alibabacloud.com/help/zh/rds/apsaradb-rds-for-mysql/restore-the-data-of-an-apsaradb-rds-for-mysql-instance-from-a-physical-backup-file-to-a-self-managed-mysql-database
### 开始还原
cd /usr/local
因为备份文件太大无法使用rz -be,所以选择sftp上传 hins25487844_data_20240730052418_qp.xb
12 months ago
#### 解包
12 months ago
12 months ago
```
12 months ago
mkdir /var/mysql_bkdata/ -p
cat hins25487844_data_20240730052418_qp.xb | xbstream -x -v -C /var/mysql_bkdata/
innobackupex --decompress --remove-original /var/mysql_bkdata/
12 months ago
```
12 months ago
12 months ago
12 months ago
#### 恢复前准备
```
12 months ago
innobackupex --defaults-file=/var/mysql_bkdata/backup-my.cnf --apply-log /var/mysql_bkdata/
12 months ago
```
12 months ago
12 months ago
#### 编辑数据库配置文件
```
12 months ago
mkdir /var/mysql_newdata -p
12 months ago
vi /etc/my.cnf
12 months ago
# 修改
12 months ago
12 months ago
datadir = /var/mysql_newdata
12 months ago
```
12 months ago
12 months ago
**参数innodb_undo_tablespaces的取值需要与/var/mysql_bkdata/backup-my.cnf中的取值相同您可以使用下面的命令来查询。**
```
12 months ago
cat /var/mysql_bkdata/backup-my.cnf | grep innodb_undo_tablespaces
12 months ago
```
12 months ago
12 months ago
#### 添加
>这个值不是乱写的,是根据上面的查询命令获取到的
```
12 months ago
[mysqld]
innodb_undo_tablespaces=0
innodb_undo_directory= /var/mysql_newdata
12 months ago
```
12 months ago
12 months ago
#### 恢复数据
```
12 months ago
innobackupex --defaults-file=/etc/my.cnf --copy-back /var/mysql_bkdata/
12 months ago
```
12 months ago
12 months ago
#### 修改
```
12 months ago
vi /etc/my.cnf
12 months ago
```
#### 增加
```
12 months ago
[mysqld]
lower_case_table_names=1
12 months ago
```
12 months ago
12 months ago
#### 授权
```
12 months ago
chown -R mysql:mysql /var/mysql_newdata
12 months ago
```
12 months ago
12 months ago
#### 启动
```
12 months ago
mysqld --defaults-file=/etc/my.cnf --user=mysql --datadir=/var/mysql_newdata &
12 months ago
```
12 months ago
12 months ago
------------------------------------------------------------------------------------------------------------
12 months ago
12 months ago
#### 重置密码
```
12 months ago
/etc/init.d/mysqld stop
mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
mysql
update mysql.user set authentication_string=PASSWORD("DsideaL147258369") where user='root' and host='localhost';
flush privileges;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY 'DsideaL147258369' WITH GRANT OPTION;
flush privileges;
exit
/etc/init.d/mysqld restart
mysql -uroot -pDsideaL147258369
12 months ago
```
> Mysql5.7修改用户密码报错“Unknown trigger has an error in its body: Unknown system variable maintain_user”
12 months ago
12 months ago
> https://www.cnblogs.com/perfectCats/p/17979389
12 months ago
12 months ago
```
12 months ago
mysql> select trigger_schema,trigger_name from information_schema.triggers;
+----------------+----------------------------+
| trigger_schema | trigger_name |
+----------------+----------------------------+
| sys | sys_config_insert_set_user |
| sys | sys_config_update_set_user |
+----------------+----------------------------+
2 rows in set (0.03 sec)
mysql> drop trigger sys.sys_config_insert_set_user;
Query OK, 0 rows affected (0.06 sec)
mysql> drop trigger sys.sys_config_update_set_user;
Query OK, 0 rows affected (0.02 sec)
[root@RockyLinux local]# mv /var/mysql_newdata/mysql/user.TRG /var/mysql_newdata/mysql/user.TRG.back
12 months ago
[root@RockyLinux local]# mv /var/mysql_newdata/mysql/proxies_priv.TRG /var/mysql_newdata/mysql/proxies_priv.TRG.back
12 months ago
```
12 months ago
12 months ago
>MySQL SQL报错-ERROR 1105 (HY000): Unknown error-存储过程/事件
> https://www.modb.pro/db/518258
```
12 months ago
# Mysql ERROR 1067: Invalid default value for 字段
12 months ago
12 months ago
https://blog.csdn.net/qq_26245325/article/details/78916363
use mysql;
ALTER TABLE `mysql`.`proc` ENGINE = MyISAM;
12 months ago
ALTER TABLE `mysql`.`event` ENGINE = MyISAM;
ALTER TABLE `mysql`.`func` ENGINE = MyISAM;
```
12 months ago