博文

安装MariaDB和设置utf-8mb4字符集Li.011

图片
  1. 安装MariaDB. 二种方式, 使用默认源和自建官方源. 1.1 使用默认源 yum -y install mariadb- server mariadb- client 安装后执行, mysql_secure_installation是初始化 systemctl enable mariadb systemctl start mariadb mysql_secure_installation 1.2 使用自建官方源, 可安装MariaDB 10.5稳定版.  官方文档地址    创建MariaDB.repo vim /etc/yum.repos.d/MariaDB.repo # MariaDB 10.5 CentOS repository list - created 2021-01-14 03:58 UTC # http://downloads.mariadb.org/mariadb/repositories/ [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/ 10.5 /centos7-amd64 gpgkey =https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck = 1    再执行安装命令即可, 并初始化 yum install -y mariadb- server mariadb- client systemctl enable mariadb systemctl start mariadb # 初始化 mysql_secure_installation 2. 设置MariaDB字符集. 需要设置4个文件my.cnf, client.cnf, mysql-clients.cnf, server.cnf. 2.1 vim /etc/my.cnf 增加以下内容 [client] default-character-set = utf8mb4 [mysql] default-character-set = utf8mb4 [mysqld] character-set-client-handshake = FALSE ...

Crontab定时任务使用Li.010

  1. 使用Crontab的原因. 每次更新博客都要登录服务器(ssh延迟容易中断)手动去拉取代码, 不方便. 故设置成自动获取最新代码. 2. 选择crontab定时 查看下资源, 觉得crontab简单可行, 直接来用就好了. 3. 定时任务需需要做事情. 特定目录执行git pul的shell脚本. 这里配置ssh key vim git_pull.sh #!/bin/bash # 进入目录中 cd ~/nginx-hugoBlog/lizicai.com/ # 拉取github中的代码 git pull 添加crontab任务文件 vim git_pull.cron # 设置5分钟拉取一次代码 */5 * * * * cd /root && ./git_pull.sh 把定时任务文件内容加到crontab中 # 添加root账户中 crontab -uroot git_pull.cron # 查询当前任务, root是账户, 添加的定时任务会放到这个目录中 crontab -uroot -l cat /var/spool/cron/root # 删除root用户的定时任务 crontab -uroot -r 日志的地址, 相当重要. # 日志文件 /var/spool/mail/root # 查看日志 # 可以把时间设置1分钟, 可以很快看到执行情况, 方便调试. tail -f / var /spool/mail/root 4. crontab 时间配置 # 格式是 # 分 时 月份中第日 月份 星期中第几天 运行的命令 # 每分钟执行一次, */1 * * * * 命令 # 每小时第20, 30分钟执行一次 20 ,30 * * * * 命令 # 8-20时, 每小时第20, 30分执行一次 20 ,30 8 -20 * * * 命令 # 每2天执行一次命令 0 0 */2 * * 命令 # 周六周日执行命令 0 0 0 0 6 ,0 命令 # 每月初一, 十五去执行 0 0 1 ,15 * * 命令

Ag Fasd Fzf终端模糊搜索神器Li.009

图片
     ag比grep快速的速度, 同时打印出搜索词的行数. Fasd 时空机, 瞬间跳到去过的目录, 或定位打开过的文件. Fzf 模糊搜索工具. 1. 安装ag fasd fzf 1.1 Mac安装ag fasd fzf. brew install the_silver_searcher fzf fasd # 以下内容添加到~/.zshrc或~/.bashrc中 eval " $(fasd --init auto) " # 重新生效 source ~/.zshrc 或 source ~/.bashrc 1.2 Linux安装ag fasd fzf. yum install the_silver_searcher fasd git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf ~/.fzf/ install 2. 别名 alias jan= 'fasd -a' # any alias js= 'fasd -si' # show / search / select alias jd= 'fasd -d' # directory alias jf= 'fasd -f' # file alias jsd= 'fasd -sid' # interactive directory selection alias jsf= 'fasd -sif' # interactive file selection alias j= 'fasd_cd -d' # cd, same functionality as j in autojump alias jz= 'fasd_cd -d -i' # cd with interactive selection alias jdd= 'fasd -D' # 删除一个路径 alias v= 'jf -e vim' alias nv= ...

Homebrew Mac下最好用的软件管理工具Li.008

图片
  1. Homebrew是什么? Homebrew能做什么? Homebrew是Mac下神一样的软件管理工具. Homebrew几乎安装任何你想到的开源软件(没有界面Gui的, 有界面的) Homebrew同样支持相当多的商业应用安装, 像jetbrains IDEA全家桶, 网易云音乐 QQ也都支持. 2. Homebrew 安装 打开终端Terminal, 输入下面命令即可. /bin/bash -c " $(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh) " 3. Homebrew 使用. 3.1 brew install –cask与brew install合并为brew install. brew install 可安装有界面或无界面的软件与应用. # 搜索软件 brew search git brew search google-chrome # 安装 brew install vim brew install neteasemusic # 重新安装 brew reinstall vim brew reinstall neteasemusic # 升级软件 brew upgrade curl brew upgrade google-chrome # 不升级软件 brew pin curl # 卸载软件与应用 brew uninstall git brew uninstall QQ # 查看软件与应用 brew info git brew info sourcetree brew list # 启动软件 brew services start mariadb # 重新启动软件 brew services restart nginx # 关闭软件 brew services stop mariadb 3.2 使用别名, 更快速, 下面别名写~/.zshrc或~/.bashrc中, source ~/.zshrc或.bashrc重新生效. alias bsearch= 'brew search' ali...

Oh My Zsh配置和插件 终端神器Li.007

图片
1. Oh My Zsh是什么 Oh My Zsh是一个开源的、社区驱动的框架,用于管理zsh 配置。让天下没有难用的终端(Terminal). 适用于Mac Linux平台. 2. Oh My Zsh安装,  Oh My Zsh官网 sh -c " $(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh) " 3. Oh My Zsh插件, Git zsh-autosuggestions fasd zsh-syntax-highlighting 让终端起飞. 3.1 Git插件, Oh My Zsh自带, 把所有的git命令做了别名, 更快使用git命令. 在~/.zshrc中启用 plugins =(git) # 终端内 # gb 等于 git branch # st 等价git status # gcmsg 等于 git commit -m # gm 等于git merge # gco 等于git checkout 全部别名地址 3.2 zsh-autosuggestions 显示之前运行的命令, 按<control + e>即可补全.    安装zsh-autosuggestions zsh-autosuggestions安装官网 git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom} /plugins/zsh-autosuggestions    在~/.zshrc中启用 plugins =(git zsh-autosuggestions)    重新生效 sourch ~/.zshrc    效果展示, Control + e即可补全 3.3 fasd时空机, 可以跳到任何之前去过的目录, 再也不必cd来cd去了, 可以和更多的命令连用. fasd可以记录访问目录的权重, 常访问目录权重高, 匹配放在前面.    安装fasd brew install fasd ...