Home > Article > Backend Development > Install MySQL using tar.gz method under Apple mac os x
On Mac systems, to install MySQL Server, you usually use the DMG package and follow the prompts on the graphical interface. In addition, MySQL also provides the Compressed TAR Archive binary package installation method, which requires no installation and decompression of the runtime version. Compared with the DMG package, no installation is required. The versioning process is more concise, with pure command line operation, which is more in line with the tossing spirit of coders.
系统环境: OS X Yosemite 10.10.3 登录用户: wid (有 sudo 权限) MySQL版本: 5.6.24 (mysql-5.6.24-osx10.9-x86_64.tar.gz) MySQL下载: http://dev.mysql.com/downloads/mysql/
Find the location of the downloaded MySQL tar.gz file. The browser download is usually in the Downloads directory of the current user, that is, /Users/97c7e4dfd49bfdcdac7a7aaf738cb62b/Downloads. Enter the terminal and decompress the tar.gz file:
cd /Users/<YourName>/Downloads tar zxvf mysql-5.6.24-osx10.9-x86_64.tar.gz
Decompression completed Finally, you get the mysql-5.6.24-osx10.9-x86_64 directory, and move the decompression directory to the MySQL default installation path /usr/local/mysql. If the /usr/local path does not exist, create it with sudo mkdir /usr/local first.
# 移动解压后的二进制包到安装目录 sudo mv mysql-5.6.24-osx10.9-x86_64 /usr/local/mysql # 更改 mysql 安装目录所属用户与用户组 cd /usr/local sudo chown -R root:wheel mysql # 执行 scripts 目录下的 mysql_install_db 脚本完成一些默认的初始化(创建默认配置文件、授权表等) cd /usr/local/mysql sudo scripts/mysql_install_db --user=mysql
Installation completed, test start, restart and stop:
cd /usr/local/mysql # 启动 sudo support-files/mysql.server start # 重启 sudo support-files/mysql.server restart # 停止 sudo support-files/mysql.server stop
Initialize MySQL root password
cd /usr/local/mysql/bin ./mysqladmin -u root password <your-password>
Connect to the database through the built-in MySQL Client
cd /usr/local/mysql/bin ./mysql -u root -p <your-password>