建立自己profile路径应该在/Users/yourname/,最后要运行. ./.profile使文件生效,和windows中给添加环境变量是一个道理,还可以看出linux和UNIX默认运行路径为

export PATH=/opt/local/bin:/opt/local/sbin:$PATH。
另外默认未修改用户可用mysql  -uroot -proot -P3306进行登录。

If you have MAMP installed on your Mac OS X box, you're probably going to want command line access to those applications at some point. Assuming you're running a default install you'll run into difficulty when you type php or mysql without logging into the appropriate directory. In MAMP the directories are as follows:

/Applications/MAMP/bin/php5/bin/php
/Applications/MAMP/Library/bin/mysql

Rather than referencing those full paths every time you'll probably want to include them in the PATH. You can do this by editing your .profile file. (You can get to the directory where this lives by typing cd).

Use a text editor to open up .profile and change the following line:

export PATH=/opt/local/bin:/opt/local/sbin:$PATH

To include the additions to the $PATH like so:

export PATH=/Applications/MAMP/Library/bin/:/Applications/MAMP/bin/php5/bin/:/opt/local/bin:/opt/local/sbin:$PATH

You'll probably need to make the shell reload your profile like so:

. ./.profile
../表示源文件所在目录的上一级目录
"."--代表目前所在的目录

Also if you have any problems connecting to mysql you may need to run the following command:

sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock

Thanks to the following blog entries:
http://www.tech-recipes.com/rx/2621/os_x_change_path_environment_variab…

更新:

以上方法是通过更改个人命令行配置文件.profile来达到寻找到指定可运行程序目录的目的,之前更改可行,但是在重新启动系统后须重新运行

. ./.profile使个人配置文件生效,但不知道什么原因再次使用就不再管用了,后来通过直接更改bash的配置文件.bash_profile,
(1)vim ~/.bash_profile;
(2)添加export PATH=/Applications/MAMP/Library/bin/:/Applications/MAMP/bin/php5/bin/:/opt/local/bin:/opt/local/sbin:$PATH
(3)保存退出; 
(4)source ~/.bash_profile;
注意,直接修改bash配置文件一定要把路径配置完整,每一个路径是用:分隔开的,如果路径配置不完整将导致整个bash解释器基本命令都用不了了!
好吧,继续总结整个基础命令都用不了的解决办法:
在新的commond line窗口中输入以下命令:
export PATH=/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
然后在sudo模式下回去重新修改原配置文件为完整状况。我这里的是:

export PATH=/Applications/MAMP/Library/bin/:/Applications/MAMP/bin/php/php7.1.8/bin/:/opt/local/bin:/opt/local/sbin:$PATH

 

Getting command line access to PHP and MySQL running MAMP on OSX的更多相关文章

  1. Mysql: [Warning] Using a password on the command line interface can be insecure

    mysql: [Warning] Using a password on the command line interface can be insecure MySQL 5.6 警告信息 comma ...

  2. how to import a SQL file in MySQL command line

    how to import a SQL file in MySQL command line execute .sql file, macOS $mysql> source \home\user ...

  3. MySQL 5.7 Command Line Client输入密码后闪退和windows下mysql忘记root密码的解决办法

    MySQL 5.7 Command Line Client输入密码后闪退的问题: 问题分析: 1.查看mysql command line client默认执行的一些参数.方法:开始->所有程序 ...

  4. mysql 乱码问题(程序界面显示正常,mysql command line显示乱码)

    今天用java写一个程序,用的是mysql数据库.界面出现乱码,然后写了一个过滤器结果了乱码问题. 但是,当我在mysql command line 中查询数据的时候,在界面上显示正常的数据,在mys ...

  5. MySQL 5.6 Warning: Using a password on the command line interface can be insecure

    MySQL 5.6 在命令行输入密码,就会提示这些安全警告信息. Warning: Using a password on the command line interface can be inse ...

  6. MySQL 5.6 警告信息 command line interface can be insecure 修复

    在命令行输入密码,就会提示这些安全警告信息. Warning: Using a password on the command line interface can be insecure.   注: ...

  7. MySQL中MySQL X.X Command Line Client一闪而过的问题

    问题介绍:我安装完MySQL(我安装的是5.5)后,使用MySQL 5.5 Command Line Client,每次点击,总是一闪而过.解决方法如下:      首先进入cmd 切入MySQL的安 ...

  8. Mysql安装后打开MySQL Command Line Client闪退解决方法

    1.开始菜单下;Mysql--->mysql server 5.6-->mysql command line Client ---右击,选择属性 2.在属性下查看目标位置: 3.将安装目录 ...

  9. mysql 备份报错mysqldump: [Warning] Using a password on the command line interface can be insecure.

    -------------------------------------------------------------------------------- mysql 备份报错mysqldump ...

随机推荐

  1. ElasticSearch(三) ElasticSearch中文分词插件IK的安装

    正因为Elasticsearch 内置的分词器对中文不友好,会把中文分成单个字来进行全文检索,所以我们需要借助中文分词插件来解决这个问题. 一.安装maven管理工具 Elasticsearch 要使 ...

  2. debug教程

    名称 解释 格式 a (Assemble) 逐行汇编 a [address] c (Compare) 比较两内存块 c range address d (Dump) 内存16进制显示 d [addre ...

  3. mspdb100.dll不见了的解决办法

    一.如果在运行某软件或编译程序时提示缺少.找不到mspdb100.dll等类似提示,将下载来的mspdb100.dll拷贝到指定目录即可 (一般是system系统目录或放到软件同级目录里面),或者重新 ...

  4. C++类中成员变量的初始化总结(转帖)

    本文转自:C++类中成员变量的初始化总结 1. 普通的变量:      一般不考虑啥效率的情况下 可以在构造函数中进行赋值.考虑一下效率的可以再构造函数的初始化列表中进行.  1 class CA  ...

  5. kali 安装最新firefox的悲惨经历

    最新的的firefox用的是量子内核,在windows上面的确感觉相比之前的firefox快了好多 想把kali 2017虚拟机的也替换掉 按照步骤: 1 添加源: /etc/apt/sources. ...

  6. 20145307第四次JAVA学习实验报告

    20145307实验四 Android开发基础 实验内容 基于Android Studio开发简单的 Android应用并部署测试; 了解Android组件.布局管理器的使用: 掌握Android中事 ...

  7. C/C++中RAND_MAX的用法

    RAND_MAX是C中stdlib.h中宏定义的一个字符常量: #define RAND_MAX Ox7FFF 其值最小为32767,最大为2147483647 通常在产生随机小数时可以使用RAND_ ...

  8. 再也不学AJAX了!(三)跨域获取资源 ② - JSONP & CORS

    浏览器的"同源策略"固然保障了互联网世界的数据隐私与数据安全,但是如果当我们需要使用AJAX跨域请求资源时,"同源策略"又会成为开发者的阻碍.在本文中,我们会简 ...

  9. linux网络连接的查看和端口的监听

    网络软件都是由客户端和服务端组成,由服务端在服务器上监听指定的端口处理接收到的数据,而客户端是向服务器端监听的端口发送数据,并由服务器端对该数据进行处理,然后将处理结果返回给客户端. 那么我们在lin ...

  10. LeetCode——remove-duplicates-from-sorted-list-ii

    Question Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only dist ...