Mac 下 MySQL 的安装配置

2014/5/16 posted in  软件配置 comments

自动安装

  1. 安装

    brew install mysql
    
  2. 初始化 root 用户密码

    mysqladmin -uroot password 密码
    
  3. 设置允许 root 用户远程访问

    $ mysql -uroot -proot_password
    mysql> grant all privileges on *.* to 'root'@'%' identified by 'root_password';
    mysql> FLUSH PRIVILEGES;
    

手动安装

  1. 安装:

    tar zxvf mysql-5.1.45-osx10.6-x86_64.tar.gz
    sudo mv mysql-5.1.45-osx10.6-x86_64 /usr/local/mysql
    cd /usr/local
    sudo chown -R root:wheel mysql  
    cd /usr/local/mysql
    sudo scripts/mysql_install_db --user=mysql
    sudo chown -R mysql data
    
  2. 使用

    cd /usr/local/mysql
    sudo support-files/mysql.server start|stop|restart|status