配置 MAMP 以使用 mariadb

发布于 2024-11-16 12:58:47 字数 235 浏览 3 评论 0原文

我成功安装了 mariadb,但 MAMP 继续使用位于其 bin 文件夹中的 mysql 副本;具体来说:

/Applications/MAMP/Library/bin/mysql

如何让 MAMP 使用 mariadb,在我的例子中,它位于 /usr/local/bin/mysql 中?

我尝试在 MAMP 的 bin 文件夹中创建一个符号链接以指向 /usr/local/bin,但这不起作用。唔。

I successfully installed mariadb, but MAMP continues to use the copy of mysql located in its bin folder; specifically:

/Applications/MAMP/Library/bin/mysql

How do I get MAMP to use mariadb, which in my case is located in /usr/local/bin/mysql?

I tried creating a symbolic link in MAMP's bin folder to point to /usr/local/bin, but that didn't work. Hmm.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜味拾荒者 2024-11-23 12:58:48

MAMP 使用 MAMP/bin/startMysql.sh 启动 mysql。尝试改变它。

MAMP uses MAMP/bin/startMysql.sh to start mysql. Try to change it.

梦一生花开无言 2024-11-23 12:58:48

这是我的做法,这样你就可以使用 mysql 或 mariadb,因为 mariadb 是一个替代品(凭记忆输入,所以如果有错误请告诉我)...

0) 备份你的 mysql 数据库dir 以防万一,并做一些 mysql 准备以防万一

$ cp -R /Applications/MAMP/db/mysql /Applications/MAMP/db/mysql.2013-02-06-1850.bak
$ /Applications/MAMP/bin/repairMysql.sh
$ /Applications/MAMP/bin/quickCheckMysqlUpgrade.sh
$ /Applications/MAMP/bin/upgradeMysql.sh

1) 复制或记下 my.cnf 文件中的一些设置。它可以位于各种不同的地方,因此要找到它们(有很多):

$ locate my.cnf
/Applications/MAMP/conf/my.cnf
/etc/my.cnf
/usr/local/etc/my.cnf
/usr/local/etc/my.cnf.d
/usr/local/etc/my.cnf.d/client.cnf
/usr/local/etc/my.cnf.d/mysql-clients.cnf
/usr/local/etc/my.cnf.d/server.cnf

2)找出加载了哪个 my.cnf(对于 MAMP,它可能位于 /Applications/MAMP/conf/my.cnf 中) cnf)

$ /usr/local/bin/mysql --help | grep my.cnf
order of preference, my.cnf, $MYSQL_TCP_PORT,
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf 
$ /Applications/MAMP/Library/bin/mysql --help | grep my.cnf
order of preference, my.cnf, $MYSQL_TCP_PORT,
/etc/my.cnf /etc/mysql/my.cnf /Applications/MAMP/conf/my.cnf ~/.my.cnf

3) 在 /etc/my.cnf 中备份 my.cnf 并编辑 my.cnf 以确保其中有一些参数,最重要的是端口、套接字和 datadir 设置,以便 mariadb 知道在哪里查找您的数据库文件:

$ sudo cp /etc/my.conf /etc/my.cnf.2013-02-06-1858.bak
$ sudo vi /etc/my.cnf
port     = 3306
socket   = /Applications/MAMP/tmp/mysql/mysql.sock 
datadir  = /Applications/MAMP/db/mysql
tmpdir   = /Applications/MAMP/tmp/mysql

4)在 [mariadb] 部分中添加您可能需要的任何 mariadb 特定配置选项

5)安装 mariadb (我喜欢使用brew,但选择您的毒药)...并且您可以随时执行此操作

$ brew install mariadb

6) 从第二步中的 my.conf 创建一个符号链接

$ sudo ln -s /Applications/MAMP/conf/my.cnf /etc/my.cnf

6a) 你可以将 my.cnf 放在任何地方,只要 /etc/my.cnf 中有一个副本或链接...这里的目标是有玛丽亚数据库和 MAMP 的 mysql 实现使用相同的配置设置。

7) 现在创建一个 shell shell 脚本来加载 apache 和 mariadb

$ mkdir -p ~/scripts/mamp
$ touch ~/scripts/mamp/startSomething.sh ~/scripts/mamp/stopSomething.sh
$ chmod ug+rx ~/scripts/mamp/*Something.sh

8) 获取/记下 apache 的当前启动/停止脚本(它可能不会有什么奇特的)

$ more /Applications/MAMP/bin/startApache.sh
$ more /Applications/MAMP/bin/stopApache.sh

9) 获取安装的 mariadb 路径,然后 make确保它是 mariadb 版本

$ which mysql
/usr/local/bin/mysql
$ mysql --version
mysql  Ver 15.1 Distrib 5.5.29-MariaDB, for osx10.8 (i386) using readline 5.1

10) 现在编辑 startSomething.sh

# /bin/sh
/Applications/MAMP/Library/bin/apachectl start
/usr/local/bin/mysql.server start &

11) 对 stopSomething.sh 执行相同操作

# /bin/sh
/Applications/MAMP/Library/bin/apachectl stop
/usr/local/bin/mysql.server stop &

12) 就是这样! 来启动或停止操作

$ ~/scripts/mamp/startSomething.sh
$ ~/scripts/mamp/stopSomething.sh

如果您想要普通 MAMP,请使用 MAMP 附带的 MAMP 应用程序 。否则,就可以享受这个速度稍快的数据库带来的乐趣...但请记住,虽然 mariadb 在设计上是 mysql 的替代品,但反之则不然 (MariaDB v MySQL 兼容性)

here's how i do it so that you can use either mysql or mariadb since mariadb is a drop in replacement (typing this from memory, so please let me know if there are some mistakes)...

0) make a backup of your mysql db dir just in case, and do some mysql prep just in case

$ cp -R /Applications/MAMP/db/mysql /Applications/MAMP/db/mysql.2013-02-06-1850.bak
$ /Applications/MAMP/bin/repairMysql.sh
$ /Applications/MAMP/bin/quickCheckMysqlUpgrade.sh
$ /Applications/MAMP/bin/upgradeMysql.sh

1) make a copy or take note of some settings in your my.cnf file. It can be located in a variety of different places, so to find them all (there are a bunch):

$ locate my.cnf
/Applications/MAMP/conf/my.cnf
/etc/my.cnf
/usr/local/etc/my.cnf
/usr/local/etc/my.cnf.d
/usr/local/etc/my.cnf.d/client.cnf
/usr/local/etc/my.cnf.d/mysql-clients.cnf
/usr/local/etc/my.cnf.d/server.cnf

2) figure out which my.cnf was loaded (for MAMP, it MAY be in /Applications/MAMP/conf/my.cnf)

$ /usr/local/bin/mysql --help | grep my.cnf
order of preference, my.cnf, $MYSQL_TCP_PORT,
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf 
$ /Applications/MAMP/Library/bin/mysql --help | grep my.cnf
order of preference, my.cnf, $MYSQL_TCP_PORT,
/etc/my.cnf /etc/mysql/my.cnf /Applications/MAMP/conf/my.cnf ~/.my.cnf

3) make a backup of the my.cnf in /etc/my.cnf and edit my.cnf to make sure it's got a few parameters in there, most importantly the port, socket, and datadir settings so that mariadb will know where to look for your db files:

$ sudo cp /etc/my.conf /etc/my.cnf.2013-02-06-1858.bak
$ sudo vi /etc/my.cnf
port     = 3306
socket   = /Applications/MAMP/tmp/mysql/mysql.sock 
datadir  = /Applications/MAMP/db/mysql
tmpdir   = /Applications/MAMP/tmp/mysql

4) add any mariadb specific config options you may want in a [mariadb] section

5) install mariadb (i like using brew, but pick your poison)... and you can really do this any time

$ brew install mariadb

6) make a symbolic link from the my.conf from step two

$ sudo ln -s /Applications/MAMP/conf/my.cnf /etc/my.cnf

6a) you can put your my.cnf anywhere, as long as there's a copy or link to it in /etc/my.cnf... the goal here is to have mariadb and MAMP's implementation of mysql use the same config settings.

7) now make a shell shell script to load apache and mariadb

$ mkdir -p ~/scripts/mamp
$ touch ~/scripts/mamp/startSomething.sh ~/scripts/mamp/stopSomething.sh
$ chmod ug+rx ~/scripts/mamp/*Something.sh

8) get/take note of the current start/stop script for apache (it'll prob won't be anything fancy)

$ more /Applications/MAMP/bin/startApache.sh
$ more /Applications/MAMP/bin/stopApache.sh

9) get the installed mariadb path, and make sure it's the mariadb version

$ which mysql
/usr/local/bin/mysql
$ mysql --version
mysql  Ver 15.1 Distrib 5.5.29-MariaDB, for osx10.8 (i386) using readline 5.1

10) now edit startSomething.sh

# /bin/sh
/Applications/MAMP/Library/bin/apachectl start
/usr/local/bin/mysql.server start &

11) do the same for stopSomething.sh

# /bin/sh
/Applications/MAMP/Library/bin/apachectl stop
/usr/local/bin/mysql.server stop &

12) that's it!. to start or stop things

$ ~/scripts/mamp/startSomething.sh
$ ~/scripts/mamp/stopSomething.sh

if you want the vanilla MAMP, use the MAMP app that came with MAMP. otherwise, have fun with this slightly faster database with a bunch of fun new features... but keep in mind that while mariadb is by design a drop in replacement for mysql, it's not true the other way around (MariaDB v MySQL compatibility)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文