分类 编程小工具 下的文章

Git相关资源

Git官网: https://git-scm.com

TortoisGit官网:https://tortoisegit.org

Sourcetree官网:https://www.sourcetreeapp.com/

Git命令(官方网站: https://git-scm.com/docs

删除远程仓库的地址
$ git remote rm origin
重置到提交 (恢复到f4df19d提交)
$ git reset --hard f4df19d
重置到远程自己最后一次提交(有可能会抹掉别人的提交)
$ git push origin HEAD --force
取消上一次本地提交(同时清空提交的内容)
$ git reset HEAD~ && git checkout . && git clean -xdf
清除本地提交
$ git reset --hard FETCH_HEAD
清除缓存区所有的内容(不包含本地提交)
$ git checkout . && git clean -xdf

添加远程地址(比如远程地址:git@git.kjwoo.cn:bowen/test.git)
$ git remote add origin git@git.kjwoo.cn:bowen/test.git
修改远端地址
$ git remote set-url origin xxx

使用yum安装git2.X(wandisco的yum源)
[root@wkjhost ~]# yum install http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-1.noarch.rpm
[root@wkjhost ~]# yum install git

git push到远程分支时报错error: RPC failed; HTTP 411 curl 22 The requested URL returned error: 411 Length Req
git config http.postBuffer 524288000

清理本地存储
$ git gc --prune=now
$ git remote prune origin

使用合并策略

git config --global pull.rebase true
git config --global branch.autoSetupRebase always

标签

//创建标签
git tag -a 标签名字 -m "标签注释"
//推送所有的分支到远端
git push origin --tags

sourcetree 还原配置

确保SourceTree已关闭。
  
确保在删除文件之前在以下文件夹中备份文件
  
删除~/Library/Application Support/SourceTree/
中的所有内容   
删除~/Library/Preferences/com.torusknot.SourceTreeNotMAS.plist(您应该使用SourceTree的直接版本,因此“NotMAS”)

nginx配置

配置nginx上传文件限制

新建一个配置用于存放文件限制
[root@wkjhost ~]# vi /etc/nginx/conf.d/file.conf

server_tokens on;
#优化服务器域名的散列表大小 
server_names_hash_bucket_size 64;
server_names_hash_max_size 2048;
sendfile on;#开启高效文件传输模式
tcp_nopush on;#减少网络报文段数量
tcp_nodelay on;#提高I/O性能
keepalive_timeout 600;#连接超时时间定义
client_header_timeout 600;#读取客户端请求头数据的超时时间
client_body_timeout 600;#读取客户端请求主体的超时时间
send_timeout 600;#响应客户端的超时时间
client_max_body_size 100m;#上传文件的大小限制

预请求

if ($request_method = OPTIONS ) {
    add_header Access-Control-Allow-Origin "*";
    add_header Access-Control-Allow-Methods "POST, GET, PUT, OPTIONS, DELETE";
    add_header Access-Control-Max-Age "3600";
    add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization";
    add_header Content-Length 0;
    add_header Content-Type text/plain;
    return 200;
}

备注: 需要放在location节点下面

yarn错误The engine "node" is incompatible with this module

yarn config set ignore-engines true

转发简单例子

server{
  listen 80;
  server_name  kjwoo.cn.test;
  index  index.php index.html index.htm;

  location / {
     proxy_pass  http://192.168.1.9:3300;
  }
}

写日志

server{
  listen 80;
  server_name  kjwoo.cn.test;
  index  index.php index.html index.htm;
  log_format  log_json  '{"@timestamp": "$time_local","user_ip":"$http_x_real_ip","lan_ip":"$remote_addr","log_time":"$time_iso8601","user_req":"$request","http_code":"$status","body_bytes_sents":"$body_bytes_sent","req_time":"$request_time","user_ua":"$http_user_agent"}';
  access_log  /var/log/nginx/access.log  log_json;

  location / {
     proxy_pass  http://192.168.1.9:3300;
  }
}

GCC版本安装或者升级(yum方案)

[root@wkjhost ~]# yum install centos-release-scl
[root@wkjhost ~]# yum install devtoolset-7-gcc*
[root@wkjhost ~]# scl enable devtoolset-7 bash
[root@wkjhost ~]# which gcc
[root@wkjhost ~]# gcc --version

mariadb基础命令

查看数据表的数据表的物理路径
MariaDB [(none)]> show global variables like '%datadir%'

使用'READ-COMMITTED'作为默认隔离级别
MariaDB [(none)]> SET GLOBAL tx_isolation='READ-COMMITTED';

创建用户并授权(把newddb数据库分配给adduser用户并设置密码为:adduser123)
MariaDB [(none)]> grant all privileges on newddb.* to adduser@'localhost' identified by 'adduser123';

创建utf8mb4编码的数据库(数据库名称:newdb)
MariaDB [(none)]> CREATE DATABASE newdb DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_general_ci;

创建utf8编码的数据库(数据库名称:newdb)
MariaDB [(none)]> CREATE DATABASE newdb DEFAULT CHARSET utf8 COLLATE utf8_general_ci;

刷新权限表
MariaDB [(none)]> flush privileges;

删除用户(用户名:testuser)
MariaDB [(none)]> drop user testuser

删除数据库(用户名:testdb)
MariaDB [(none)]> drop database testdb

查看连接数
[root@wkjhost ~]# mysqladmin -uroot -p123 processlist

查看配置遍历
MariaDB [(none)]> show variables like '%query_cache%'

初始化数据库密码: root_pwd
[root@wkjhost ~]# mysql_secure_installation

centos7安装mariadb 10

添加 MariaDB 的YUM配置文件MariaDB.repo文件
[root@wkjhost ~]# vi /etc/yum.repos.d/MariaDB.repo

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

安装 MariaDB
[root@wkjhost ~]# yum install MariaDB-server -y

mariadb基础命令问题解决

数据库启动不了

查看数据库日志
[root@wkjhost ~]# vi /var/log/mariadb/mariadb.log

进入数据库的数据目录,清除logfile文件
[root@wkjhost ~]# rm -f /uar/lib/mysql/ib_logfile*

检查数据库端口是否被占用
[root@wkjhost ~]# netstat -tunpl | grep 3306

数据库进不去(密码不正确)

停止数据库服务
[root@wkjhost ~]# systemctl stop mariadb

跳过权限表进行启动(登录数据库就不用密码)
[root@wkjhost ~]# mysqld_safe --skip-grant-tables &

直接登录数据库(直接点击确定就行)
[root@wkjhost ~]# mysql -uroot -p

修改密码
MariaDB [(none)]> update mysql.user set password=password("root_pwd") where user="root";
MariaDB [(none)]> quit

杀死mysql进程,启动mysql服务
[root@wkjhost ~]# kill `netstat -tunpl | grep 3306 | awk -F' ' '{ print $7 }'|awk -F'/' '{print $1}'`
[root@wkjhost ~]# systemctl start mariadb

Mysql8密码问题

问题:发现登录不了,报错:navicat不支持caching_sha_password加密方式
原因:mysql8.0使用新的密码加密方式:caching_sha_password
解决方式:修改成旧的加密方式(mysql_native_password),并重置密码

select host,user,plugin from user;
alter user 'root'@'%' identified with mysql_native_password by 'root';

SQL语句收集

把table_name表中的key字段中的“table.”修改为“entity.”的sql语句

UPDATE `table_name` SET `key` = REPLACE(`key`, 'table.', 'entity.') WHERE `key` LIKE 'table.%';