Zengliwei 开发笔记
常用命令及参数
npm 库
原生库 |
npm config set registry https://registry.npmjs.org/
|
阿里库 |
npm config set registry https://registry.npmmirror.com/
|
Linux 命令
用户组及权限
更改文件所有者 |
chown -R www:www .
|
更改文件权限 |
find ./ -type f -print|xargs chmod 644;
find ./ -type d -print|xargs chmod 755;
|
打包及解压
.tar 解包 |
tar xvf FileName.tar
|
.tar 打包 |
tar cvf FileName.tar DirName
|
.tar.gz 和 .tgz 解压 |
tar zxvf FileName.tar.gz
|
.tar.gz 和 .tgz 压缩 |
tar zcvf FileName.tar.gz \
--exclude=app/etc/env.php \
--exclude=generated \
--exclude=pub/media \
--exclude=pub/static \
--exclude=var \
.
|
.zip 解压 |
unzip FileName.zip
|
.zip 压缩 |
zip FileName.zip DirName
|
.bz2 解压 |
bzip2 -d FileName.bz2
tar -xjvf xxx.bz2
|
.bz2 压缩 |
bzip2 -z FileName
|
GIT
合并分支
执行以下操作之前先 checkout 到目标分支:
合并指定本地分支到当前分支 |
git merge branch
|
合并指定提交到当前分支 |
git cherry-pick COMMIT_ID
|
导出文件
最后一次提交修改的文件 |
git archive --output=latest.tar HEAD \
$(git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT HEAD^)
|
指定版本与最后一次提交相异的文件 |
git archive --output=latest.tar HEAD \
$(git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT OLD_COMMIT_ID HEAD)
|
指定的两个版本间相异的文件 |
git archive --output=latest.tar COMMIT_ID_2 \
$(git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT COMMIT_ID_1 COMMIT_ID_2)
|
克隆代码库
指定分支克隆库文件到当前文件夹 |
git clone username@http://path/to/git -b branch .
|
在 GIT 中忽略本地文件 |
git update-index --skip-worktree path/to/file
|
MySQL
访问数据库
mysql --default-character-set utf8 -u root -p
导入数据
USE `database`;
SET FOREIGN_KEY_CHECKS = 0;
source database_source_file.sql;
导出数据
mysqldump -h localhost -u root -p 'database' > 'database_source_file.sql'
创建数据库
CREATE DATABASE `database` CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_unicode_ci';
用户权限
GRANT Alter, Create, Create Temporary Tables, Delete, Drop, Execute, Index, Insert, References, Select, Update ON `database`.* TO `username`@`localhost`;
重设 root 密码
- 修改 MySQL 配置文件,在
[mysqld]
下增加一行 skip-grant-tables
- 重启 MySQL 服务:
systemctl stop mysqld
,systemctl start mysqld
- 执行 SQL 清空权限:
FLUSH PRIVILEGES;
- 执行 SQL 修改密码:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';
常用资源