Mac OS X安装MySQL步骤

本文详细介绍了在MacOS环境下手动安装MySQL的过程,包括创建目录、下载并解压二进制分发包、配置MySQL用户及组、安装MySQL、设置开机启动等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

# create the directory where you will keep your MySQL binary distribution
mkdir ~/src
cd ~/src
 
# download mysql binary distribution from http://dev.mysql.com/downloads/mysql/
# then move the distribution into your src directory
mv /path/to/mysql/download.tar.gz ~/src
# make sure you are in ~/src (use pwd if unsure) then untar
gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -
 
# create the MySQL group
dscl . create /Groups/mysql
# give it some group id
dscl . create /Groups/mysql gid 296
# create a MySQL user
dscl . -create /Users/mysql
# make the MySQL user a member of the MySQL group
dscl . append /Groups/mysql GroupMembership mysql
# change ownership to mysql
chown -R mysql .
chgrp -R mysql .
 
# install mysql
scripts/mysql_install_db --user=mysql
# make a symlink in the /usr/local directory or you can customize the location in support-files/mysql.server if you prefer
mkdir /usr/local
cd /usr/local/
ln -s /full/path/to/your/mysql/install/directory mysql
 
# you should now be able to start the server
support-files/mysql.server start
 
# add mysql to your PATH
# in ~/.bash_profile
export PATH=/usr/local/mysql/bin:$PATH
source ~/.bash_profile
# should bring up the mysql CLI
mysql
# exit 
mysql> exit
 
# set mysql server to auto start upon boot
mkdir /Library/StartupItems/MySQLCOM
cd /Library/StartupItems/MySQLCOM/
ln -s /usr/local/mysql/support-files/mysql.server MySQLCOM
 
# test for success
/Library/StartupItems/MySQLCOM/MySQLCOM stop
/Library/StartupItems/MySQLCOM/MySQLCOM start
 
# create a root password
mysqladmin -u root password your_root_password

 

每次重装系统后都要重新编译mysql,但是,都会出现一些小问题,导致这些问题的直接原因都是用户权限的设置。在此总结完整的安装步骤,供查阅。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值