Mac下安装XAMPP配置mysql环境变量

1、下載安裝文件,官網地址:「www.apachefriends.org

2、 输入sudo /Applications/XAMPP/xamppfiles/xampp security设置密码

3、设置mysql环境变量

访问mysql:/Applications/XAMPP/xamppfiles/bin/mysql -u root -p
修改环境变量:
1.创建并以 TextEdit 的方式打开 ~/.bash_profile 文件
touch ~/.bash_profile;

open -e .bash_profile

2.新增环境变量
export PATH=${PATH}:/Applications/XAMPP/xamppfiles/bin
3.让以上所做的配置生效
source ~/.bash_profile
4.查看是否生效(有时可能需要关闭当前 Terminal 窗口重新开启一个)
echo $PATH

5、xampp安装成功之后,有的程序可以在localhost中运行,有的却报如下问题:

<pre class="prettyprint prettyprinted" style="margin-top: 0px; margin-bottom: 18px; padding: 10px 10px 7px; color: rgb(51, 51, 51); font-family: Menlo, Monaco, Consolas, 'Lucida Console', 'Courier New', 'Microsoft Yahei', monospace; white-space: pre-wrap; line-height: 1.5em; border-style: solid; border-width: 1px 1px 1px 2px; border-color: rgb(221, 221, 221) rgb(221, 221, 221) rgb(221, 221, 221) rgb(27, 88, 184);"><code style="margin: 0px; padding: 0px; font-family: Menlo, Monaco, Consolas, 'Lucida Console', 'Courier New', 'Microsoft Yahei', monospace; background-color: transparent;"><span class="typ" style="color: rgb(102, 0, 102);">Access</span><span class="pln" style="color: rgb(0, 0, 0);"> forbidden</span><span class="pun" style="color: rgb(102, 102, 0);">!</span><span class="pln" style="color: rgb(0, 0, 0);">  </span><span class="typ" style="color: rgb(102, 0, 102);">You</span><span class="pln" style="color: rgb(0, 0, 0);"> don</span><span class="pun" style="color: rgb(102, 102, 0);">’</span><span class="pln" style="color: rgb(0, 0, 0);">t have permission to access the requested </span><span class="kwd" style="color: rgb(0, 0, 136);">object</span><span class="pun" style="color: rgb(102, 102, 0);">.</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="typ" style="color: rgb(102, 0, 102);">It</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">is</span><span class="pln" style="color: rgb(0, 0, 0);"> either read</span><span class="pun" style="color: rgb(102, 102, 0);">-</span><span class="kwd" style="color: rgb(0, 0, 136);">protected</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">or</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">not</span><span class="pln" style="color: rgb(0, 0, 0);"> readable </span><span class="kwd" style="color: rgb(0, 0, 136);">by</span><span class="pln" style="color: rgb(0, 0, 0);"> the server</span><span class="pun" style="color: rgb(102, 102, 0);">.</span></code>

 

解决办法:

可以找到apache的httpd.conf文件,找出

<Directory />
    Options All
    AllowOverride All
    Order deny,allow
    Allow from all
</Directory>

如果还不行,那就是权限的问题了

在命令中运行如下命令

chmod -R 777 /Applications/XAMPP/xamppfiles/htdocs

就可以了。

5、更改根目录(默认目录在(xapp/htdocs)

  a、 修改httpd.conf文件,找到documentroot和directory,分别改成你所需要的路径

  b、apache默认的用户组群是deamon,需要修改的成自己mac的用户名称,同样在httpd.conf文件中,user daemon改为user yourname,否则会报错403


6、配置mysql终端路径:

需要在终端命令行操作时,比如输入:mysql -u root -p,未正确配置前不会出现想要的输入密码提示,而是会提示:

command not found

原来当你输入命令的时间,系统会在/usr/bin这个位置里寻找你输入的命令,如果你没有把命令引入到这个位置,无论你直接cd到工具具体的位置调用,也是白费功夫的。只要把这个工具的绝对位置引入到/usr/bin,所有的问题就迎刃而解了,只要我们把这条命令执行: 

sudo ln -s /applications/xampp/bin/mysql /usr/bin

假如提示你权限不够:

ln: /usr/bin/mysql: Operation not permitted

把权限升高点

$ sudo ln -s /usr/local/mysql/bin/mysql /usr/bin

sudo执行还是不可以

ln: /usr/bin/mysql: Operation not permitted

还报错

$ alias mysql=/applications/xampp/bin/mysql

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值