...
This commit is contained in:
@@ -9,6 +9,17 @@ git clone by ssh
|
||||
git remote set-url origin git@192.168.2.166:3122/zhangsz/WFC/be.wfc.git
|
||||
```
|
||||
|
||||
```sh
|
||||
# 1. 生成 SSH ed25519密钥对
|
||||
ssh-keygen -t ed25519 -C "simon@omc-dev-openEuler"
|
||||
# 2. 复制公钥内容
|
||||
cat ~/.ssh/id_ed25519.pub
|
||||
# 3. 将公钥添加到 Gitee
|
||||
# 登录 Gitee -> 设置 -> SSH 公钥 -> 添加公钥
|
||||
# 4. 测试连接
|
||||
ssh -T git@192.168.2.166 -p 3122
|
||||
```
|
||||
|
||||
## docker tips
|
||||
|
||||
使用 Docker 日志清理工具
|
||||
@@ -81,3 +92,233 @@ curl --location --request POST 'https://192.168.2.249:8043/openapi/authorize/tok
|
||||
|
||||
mvn clean compile
|
||||
mvn clean package -P prod
|
||||
|
||||
## mysql/mariadb tips
|
||||
|
||||
|
||||
有几种方法可以在 MariaDB 10.5 中修改 root 密码:
|
||||
|
||||
## 方法1:使用 mysql CLI(已登录)
|
||||
|
||||
如果你能以 root 用户登录 MariaDB:
|
||||
|
||||
```bash
|
||||
sudo mysql -u root -p
|
||||
```
|
||||
|
||||
然后执行以下命令:
|
||||
|
||||
```sql
|
||||
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
|
||||
FLUSH PRIVILEGES;
|
||||
```
|
||||
|
||||
## 方法2:安全模式重置(无法登录时)
|
||||
|
||||
1. 停止 MariaDB 服务:
|
||||
|
||||
```bash
|
||||
sudo systemctl stop mariadb
|
||||
```
|
||||
|
||||
2. 以跳过权限表的方式启动 MariaDB:
|
||||
|
||||
```bash
|
||||
sudo mysqld_safe --skip-grant-tables --skip-networking &
|
||||
```
|
||||
|
||||
3. 无需密码连接到 MariaDB:
|
||||
|
||||
```bash
|
||||
sudo mysql
|
||||
```
|
||||
|
||||
4. 设置新密码:
|
||||
|
||||
```sql
|
||||
USE mysql;
|
||||
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
|
||||
FLUSH PRIVILEGES;
|
||||
EXIT;
|
||||
```
|
||||
|
||||
5. 停止并正常重启 MariaDB 服务:
|
||||
|
||||
```bash
|
||||
sudo pkill mysqld
|
||||
sudo systemctl start mariadb
|
||||
```
|
||||
|
||||
## 方法3:使用 mysql_secure_installation
|
||||
|
||||
这个工具可以帮助你重置 root 密码并优化一些安全设置:
|
||||
|
||||
```bash
|
||||
sudo mysql_secure_installation
|
||||
```
|
||||
|
||||
按照提示操作,其中会包括重置 root 密码的选项。
|
||||
|
||||
记得将示例中的 'new_password' 替换为你想要设置的实际密码。
|
||||
|
||||
simonzhangsz: ░░ The job identifier is 1143.
|
||||
Apr 27 10:40:45 omc-dev-oe22 mariadb-prepare-db-dir[9062]: Database MariaDB is probably initialized in /var/lib/mysql already, nothing is done.
|
||||
Apr 27 10:40:45 omc-dev-oe22 mariadb-prepare-db-dir[9062]: If this is not the case, make sure the /var/lib/mysql is empty before running mariadb-prepare-db-dir.
|
||||
Apr 27 10:41:15 omc-dev-oe22 systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
|
||||
|
||||
GitHub Copilot: # MariaDB Service Failure Analysis
|
||||
|
||||
Your MariaDB service is failing to start with an exit status of 1. The logs indicate:
|
||||
|
||||
1. The system believes the database is already initialized in mysql
|
||||
2. There may be an issue with the database files or configuration
|
||||
|
||||
## Troubleshooting Steps
|
||||
|
||||
1. **Check MariaDB logs for more detailed error information:**
|
||||
|
||||
```bash
|
||||
sudo journalctl -u mariadb -n 50
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```bash
|
||||
sudo cat /var/log/mysql/error.log
|
||||
```
|
||||
|
||||
2. **Check permissions on the data directory:**
|
||||
|
||||
```bash
|
||||
ls -la /var/lib/mysql
|
||||
```
|
||||
|
||||
Make sure the directory is owned by the mysql user:
|
||||
|
||||
```bash
|
||||
sudo chown -R mysql:mysql /var/lib/mysql
|
||||
```
|
||||
|
||||
3. **Check disk space:**
|
||||
|
||||
```bash
|
||||
df -h
|
||||
```
|
||||
|
||||
4. **Try safe start to see if it provides more diagnostics:**
|
||||
|
||||
```bash
|
||||
sudo mysqld_safe --skip-grant-tables
|
||||
```
|
||||
|
||||
5. **Try repairing database files:**
|
||||
|
||||
```bash
|
||||
sudo mysqlcheck --all-databases --repair --use-frm
|
||||
```
|
||||
|
||||
6. **Reset permissions and restart:**
|
||||
|
||||
```bash
|
||||
sudo chmod -R 755 /var/lib/mysql
|
||||
sudo chown -R mysql:mysql /var/lib/mysql
|
||||
sudo systemctl restart mariadb
|
||||
```
|
||||
|
||||
If the database is corrupted, you might need to backup your data (if possible) and reinitialize:
|
||||
|
||||
```bash
|
||||
sudo systemctl stop mariadb
|
||||
sudo mv /var/lib/mysql /var/lib/mysql.bak
|
||||
sudo mkdir /var/lib/mysql
|
||||
sudo chown mysql:mysql /var/lib/mysql
|
||||
sudo mysql_install_db --user=mysql
|
||||
sudo systemctl start mariadb
|
||||
```
|
||||
|
||||
After that, you would need to restore your databases from backup or recreate them.
|
||||
|
||||
simonzhangsz: 如何授权某些表的权限给用户
|
||||
|
||||
GitHub Copilot: # 如何授权某些表的权限给 MariaDB 用户
|
||||
|
||||
在 MariaDB 中,你可以为特定用户授予对某些表的权限。以下是完整的步骤:
|
||||
|
||||
## 1. 创建用户(如果尚不存在)
|
||||
|
||||
```sql
|
||||
CREATE USER 'username'@'host' IDENTIFIED BY 'password';
|
||||
```
|
||||
|
||||
例如:
|
||||
```sql
|
||||
CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypassword';
|
||||
```
|
||||
|
||||
## 2. 授予表级权限
|
||||
|
||||
基本语法:
|
||||
```sql
|
||||
GRANT permission1, permission2, ... ON database_name.table_name TO 'username'@'host';
|
||||
```
|
||||
|
||||
### 常见权限类型
|
||||
|
||||
- `SELECT` - 读取数据
|
||||
- `INSERT` - 插入数据
|
||||
- `UPDATE` - 更新数据
|
||||
- `DELETE` - 删除数据
|
||||
- `ALTER` - 修改表结构
|
||||
- `CREATE` - 创建表
|
||||
- `DROP` - 删除表
|
||||
- `ALL PRIVILEGES` - 所有权限
|
||||
|
||||
### 实例
|
||||
|
||||
授予用户对特定表的SELECT权限:
|
||||
```sql
|
||||
GRANT SELECT ON mydb.mytable TO 'myuser'@'localhost';
|
||||
```
|
||||
|
||||
授予用户对特定表的多个权限:
|
||||
```sql
|
||||
GRANT SELECT, INSERT, UPDATE ON mydb.mytable TO 'myuser'@'localhost';
|
||||
```
|
||||
|
||||
授予用户对所有表的特定权限:
|
||||
```sql
|
||||
GRANT SELECT ON mydb.* TO 'myuser'@'localhost';
|
||||
```
|
||||
|
||||
授予用户对多个表的权限:
|
||||
```sql
|
||||
GRANT SELECT ON mydb.table1 TO 'myuser'@'localhost';
|
||||
GRANT INSERT ON mydb.table2 TO 'myuser'@'localhost';
|
||||
```
|
||||
|
||||
## 3. 应用更改
|
||||
|
||||
授予权限后,刷新权限:
|
||||
```sql
|
||||
FLUSH PRIVILEGES;
|
||||
```
|
||||
|
||||
## 4. 验证权限
|
||||
|
||||
查看用户权限:
|
||||
```sql
|
||||
SHOW GRANTS FOR 'myuser'@'localhost';
|
||||
```
|
||||
|
||||
## 5. 撤销权限(如需)
|
||||
|
||||
```sql
|
||||
REVOKE permission ON database_name.table_name FROM 'username'@'host';
|
||||
```
|
||||
|
||||
例如:
|
||||
```sql
|
||||
REVOKE INSERT ON mydb.mytable FROM 'myuser'@'localhost';
|
||||
```
|
||||
|
||||
确保在赋予权限时遵循最小权限原则,只给用户执行其工作所需的权限。
|
||||
Reference in New Issue
Block a user