Mac配置 个人记录走过的坑

Mac配置、软件安装、环境配置、镜像源、等

Posted by dzt on June 1, 2019

个人便好设置:

  1. 触控板:启用所有的触控板操作,「光标与点按」中选中「轻拍来点按」,将「查找与数据检测器」的手势调整为「用三个手字轻按」
  2. 安全与隐私:设置「进入睡眠或开启屏幕保护之后」「立即」要求输入密码
  3. touch bar:用锁屏键替换Siri

基础环境设置

  1. Xcode:Xcode会包含很多开发工具,今后会用到,具体安装Xcode步骤:
# 
xcode-select --install
# 运行下面的命令看你是否成功安装:
xcode-select -p
/Library/Developer/CommandLineTools
  1. homebrewHomebrew 是 Mac 下最好的包管理工具,相当于 RH 系的 yum 和 Debian 系的 apt-get。 在 Terminal 中输入下面的命令下安装:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  1. Git 补全

尝试了很多种教程,记录成功的一个 ```shell curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash

添加到 .bash_profile

vim ~/.bash_profile

添加内容

if [ -f ~/.git-completion.bash ]; then . ~/.git-completion.bash fi

保存后刷新

source ~/.bash_profile




## 软件

1. Pycharm
2. iTerm2
3. Typora
4. Google Chrome
5. Alfred
6. Git
7. Navicat for mysql
8. …





## 更换brew镜像源

> 网上很多关于镜像源的  以下是阿里云镜像源

```shell
# 替换brew.git:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git

# 替换homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git

# 更新元信息
brew update

brew

   // 搜索包
   brew search mysql
   
   // 安装包
   brew install mysql
   
   // 查看包信息,比如目前的版本,依赖,安装后注意事项等
   brew info mysql
   
   // 卸载包
   brew uninstall wget
   
   // 显示已安装的包
   brew list
   
   // 查看brew的帮助
   brew –help
   
   // 更新, 这会更新 Homebrew 自己
   brew update
   
   // 检查过时(是否有新版本),这会列出所有安装的包里,哪些可以升级
   brew outdated
   brew outdated mysql
   
   // 升级所有可以升级的软件们
   brew upgrade
   brew upgrade mysql
   
   // 清理不需要的版本极其安装包缓存
   brew cleanup
   brew cleanup mysql

Homebrew Cask

通过Homebrew Cask优雅、简单、快速的安装和管理OS X图形界面程序,比如Google ChromeDropbox

安装

brew install caskroom/cask/brew-cask

使用

基本用法与brew相同,只不过在brew后面加了一个cask单词。

// 安装软件
brew cask install google-chrome

// 卸载软件
brew cask uninstall google-chrome

安装mysql

# 搜索mysql  brew search mysql
yanshigoudeMacBook-Pro:_posts yanshigou$ brew search mysql
==> Formulae
automysqlbackup            mysql-connector-c          mysql@5.5
mysql                      mysql-connector-c++        mysql@5.6
mysql++                    mysql-sandbox              mysql@5.7
mysql-client               mysql-search-replace       mysqltuner
mysql-cluster              mysql-utilities

==> Casks
homebrew/cask/mysql-connector-python     homebrew/cask/navicat-for-mysql
homebrew/cask/mysql-shell                homebrew/cask/sqlpro-for-mysql
homebrew/cask/mysql-utilities
# 安装mysql brew install mysql@5.7
yanshigoudeMacBook-Pro:_posts yanshigou$ brew install mysql@5.7

# 然后会很长一段时间 安装其他依赖包什么的 直到出现
==> mysql@5.7
We've installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:
    mysql -uroot

mysql@5.7 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have mysql@5.7 first in your PATH run:
  echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.bash_profile

For compilers to find mysql@5.7 you may need to set:
  export LDFLAGS="-L/usr/local/opt/mysql@5.7/lib"
  export CPPFLAGS="-I/usr/local/opt/mysql@5.7/include"


To have launchd start mysql@5.7 now and restart at login:
  brew services start mysql@5.7
Or, if you don't want/need a background service you can just run:
  /usr/local/opt/mysql@5.7/bin/mysql.server start

# 其实已经说的很明确了 首先
echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.bash_profile 
加入export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"到 .bash_profile  中 
# 再
source ~/.bash_profile 
# 开启mysql服务
mysql.server start
# 然后再
mysql_secure_installation
# 就开始设置密码 跟着一步一步走就All done!了

2019-06-01 01:01 以后再更新

python

自带了python2.7 但没有预装pip

所以用easy_install

# 不用sudo会出现权限错误
sudo eays_install pip

在用brew装mysql的时候附属依赖安装了python3.7

再来装虚拟环境Virtualenv、virtualenvwrapper

pip install virtualenv
# pip install virtualenvwrapper
# 再python2装virtualenvwrapper时,安装six会报错
# 原因是Apple预安装的这个six库出于安全原因被设置为sudo也不可以执行操作,所以
# 需要依赖于高版本的库就需要更新six,但是没有six的权限,所以就会报错。
sudo pip install six --upgrade --ignore-installed six
pip install virtualenvwrapper

pip3 install virtualenv 
pip3 install virtualenvwrapper