# 复制文件到远程服务器

scp -r directory_name root@your_ip:directory_name

# ssh免密码登陆

ssh-keygen -t rsa -P "your_password"

scp -p ~/.ssh/id_rsa.pub root@<server ip>:/root/.ssh/authorized_keys

# NPM

# 设置代理

npm config set proxy=http://127.0.0.1:1087

# 取消代理

npm config delete proxy

# Mac

# sudo免密码

sudo vi /etc/sudoers

%admin ALL=(ALL) NOPASSWD: NOPASSWD: ALL

# 查看指定端口运行的程序及其pid

losf -i tcp:3000

kill pid

# nginx

# 重启

nginx -s reload

# 查看端口使用情况

netstat -anp

# 查看内存、CPU使用情况

top

# Mysql数据库

# 文件迁移

参考mysqldump导出数据库 (opens new window)

导出:mysqldump -u root -p --databases db_name --tables table_name > your_directory

导入:mysql -u root -p db_name < your_sql_file

# Sequelize连接数据库出错

  • 错误:Unhandled rejection SequelizeConnectionError: Client does not support authentication protocol requested by server; consider upgrading MySQL client

  • 解决:

    • 进入mysql
    • use your_db_name;
    • alter user 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_password';
    • flush privileges;

# 创建用户与授权

  • CREATE USER 'username'@'host' IDENTIFIED BY 'password';

  • GRANT ALL ON *.* TO 'username'@'host';

# Docker

# 安装命令前升级apt-get

apt-get update

如果不update,就会报Unable to locate package错误

# 安装curl命令

apt install curl

# 安装ping命令

apt-get install inetutils-ping

# 安装ifconfig命令

apt-get install net-tools

# 安装ssh

apt-get install openssh-server service ssh start

# tag镜像

docker tag image username/repository:tag

其中tag代表镜像的版本

# 发布镜像

docker push username/repository:tag

# 拉取镜像

docker run -p 4000:80 username/repository:tag