標題:Go 開發環境搭建
日期:2021-08-27 11:33:00
toc:true
分類:
- Golang
標籤: - Go
- Golang
- 開發
- 環境
- 搭建
本文基於 Centos7.8 介紹了常見的開發環境工具的搭建流程及命令。
git 安裝#
-
安裝:
yum install -y git配置:
git config --global user.name "biuaxia" git config --global user.email "[email protected]" git config --global --list -
查看有無 sshKey:
ls -al ~/.ssh -
生成 sshKey:
ssh-keygen -t ed25519 -C "[email protected]" -
拷貝 sshKey 到剪貼板(貼到 Github 帳戶配置):
cat ~/.ssh/id_ed25519.pub -
驗證 git 配置:
git clone [email protected]:biuaxia/Sardine.git test/1 -
刪除 git clone 的資料夾:
rm -rf ~/test/
dockers 和 docker-compose 安裝#
docker 安裝#
- 安裝:
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun - 開啟
docker:systemctl start docker - 設置開機啟動:
docker:systemctl enable docker - 檢查是否啟動:
ps -ef|grep docker - 檢查能否執行:
docker ps -a - 配置容器鏡像加速(訪問 https://cr.console.aliyun.com/cn-hangzhou/instances,左側
鏡像工具-鏡像加速器) - 查看能否加速:
sudo docker run --name he hello-world - 刪除容器:
docker rm he - 刪除鏡像:
docker rmi hello-world
docker-compose 安裝#
- 安裝:
curl -L https://get.daocloud.io/docker/compose/releases/download/1.29.2/docker-compose-uname -s-uname -m> /usr/local/bin/docker-compose - 授權:
chmod +x /usr/local/bin/docker-compose
MySQL 安裝#
-
安裝:
docker pull mysql:5.7 -
檢查:
docker images -
運行:
docker run -p 3306:3306 --name mysql57 -v $PWD/conf:/etc/mysql/conf.d -v $PWD/logs:/logs -v $PWD/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7注意:所有可選參數前者是指容器,後者是指宿主機。例如:
-v $PWD/logs:/logs是指將容器當前目錄下的 logs 目錄掛載到宿主機的 /logs 目錄。 -
檢查:
docker ps -a -
日誌:
docker logs mysql57 -
進入:
docker exec -it mysql57 /bin/bash -
登入:
mysql -uroot -p123456 -
創建新用戶及遠程登入授權
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION; GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' IDENTIFIED BY 'root' WITH GRANT OPTION; GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'root' WITH GRANT OPTION; FLUSH PRIVILEGES; -
查詢:
select user,host from user; -
退出 MySQL:
exit -
退出容器:
exit -
放行防火牆或安全組規則
來源 協議端口 0.0.0.0/0 TCP:3306 ::/0 TCP:3306 -
通過數據庫連接工具連結,如 Navicat for MySQL。