我可以从 PHP 自动定位 MySQL 可执行文件吗? [英] Can I automatically locate the MySQL executable from PHP?

查看:56
本文介绍了我可以从 PHP 自动定位 MySQL 可执行文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要运行 Shell_exec 将转储导入到我的 MYSQL 数据库中.今天我这样做:

I need to run Shell_exec to import a dump into my MYSQL database. Today I do this:

$shellExec = 'C:\wamp\bin\mysql\mysql5.1.36\bin\mysql -h localhost -u root mertero_decicare <D:\localhost\sql\decisions.sql';

$shellExec = 'C:\wamp\bin\mysql\mysql5.1.36\bin\mysql -h localhost -u root mertero_decicare < D:\localhost\sql\decisions.sql';

$out = shell_exec($shellExec .' 2> output');

$out = shell_exec($shellExec .' 2> output');

哪个有效.但是有没有办法从 PHP 中找到"mysql 可执行文件的位置?所以我不需要硬记我的 mysql 位置?

Which works. But is there a way to 'find' the location of the mysql executable from PHP? SO I don't need to hardcaord my mysql location?

罗恩

推荐答案

一个简单的方法是将它添加到 Windows Environment 路径中(它在大多数 Unix 系统的路径中).然后你只需要从脚本中调用 mysql .

An easy way to do this is add it to the Windows Environment path (it is in the path on most Unix systems). Then you just have to call mysql from the script.

这是有关如何从 MySQL 执行此操作的信息页面:MySQL Windows 服务启动

Here is the information page on how to do it from MySQL: MySQL Windows Service Start

在那个页面上你想找到文本

And on that page you want to find the text

为了更方便的调用MySQL程序,可以将MySQL bin目录的路径名添加到你的Windows系统PATH环境变量中"

"To make it easier to invoke MySQL programs, you can add the path name of the MySQL bin directory to your Windows system PATH environment variable"

并通读该部分.使用这种方法你只需要在没有路径的情况下调用mysql.

and read through that section. Using this method you just have to call mysql without a path.

这篇关于我可以从 PHP 自动定位 MySQL 可执行文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆