简体   繁体   English

XAMPP 使用什么命令来启动 MySQL?

[英]What command does XAMPP use to start MySQL?

To start a MySQL (technically mariadb) module from the XAMPP control panel, you just click the "Start" action button.要从 XAMPP 控制面板启动 MySQL(技术上来说是 mariadb)模块,您只需单击“启动”操作按钮。 What command is being run behind the scenes for "Start"?什么命令在“开始”的幕后运行? I've tried to replicate it from the command line with a variety of commands, but I've found that the "Start" button will succeed where my command-line commands fail.我尝试使用各种命令从命令行复制它,但我发现“开始”按钮会在我的命令行命令失败的地方成功。

basically基本上

mysqld.exe --defaults-file="C:\ammpp\my.ini"

mysqld is the server command mysqld是服务器命令

the my.ini ist the configuration you have to check the folder my.ini是您必须检查文件夹的配置

And MySQL80 is the name和 MySQL80 是名字

see manual for more options更多选项请参见手册

As the github says is the command line in the batch file xampp/mysql_start.bat `正如github所说的是批处理文件xampp/mysql_start.bat的命令行`

mysql\bin\mysqld --defaults-file=mysql\bin\my.ini --standalone --console

the my.ini makes some minor changes to the default values, no trickery at all my.ini 对默认值进行了一些小的更改,根本没有技巧

命令行中的net startnet stop命令将启动和停止服务,当然包括 MySQL 或 MariaDB。

net start mariadb

I have no idea what trickery the XAMPP package uses, but if you want to start the mariadb service from the cmd, all you need is an elevated command prompt and the following line:我不知道 XAMPP 包使用了什么技巧,但是如果您想从 cmd 启动 mariadb 服务,您只需要一个提升的命令提示符和以下行:

net start MariaDB

Note: my OS is Win10注意:我的操作系统是Win10

A modification of nbk's answer worked for me in PowerShell:在 PowerShell 中对 nbk 答案的修改对我有用:

C:\xampp\mysql\bin\mysqld.exe --defaults-file="C:\xampp\mysql\bin\my.ini" --console

This shows up as running in the XAMPP Control Panel (v3.2.4) and uses the correct port from the my.ini file (I'm using port 3308).这显示为在 XAMPP 控制面板 (v3.2.4) 中运行,并使用my.ini文件中的正确端口(我使用端口 3308)。

To stop the MySQL server, you can hit Ctrl+C, but only if the MySQL server is open with the --console param.要停止 MySQL 服务器,您可以按 Ctrl+C,但--console是 MySQL 服务器已使用--console参数打开。 To stop it from another terminal I've tried various shutdown commands, but none have worked for me so I've had to use the ugly command:为了从另一个终端停止它,我尝试了各种关闭命令,但没有一个对我有用,所以我不得不使用丑陋的命令:

taskkill /FI "IMAGENAME eq mysqld.exe" /T /F

From a .bat batch file I've also found these commands useful for starting and stopping:.bat批处理文件中,我还发现这些命令对于启动和停止很有用:

:: Start
start "XamppMySQLD1" powershell -NoExit -command "& 'C:\xampp\mysql\bin\mysqld.exe' --defaults-file='C:\xampp\mysql\bin\my.ini' --console" || echo ERROR && exit /b

:: Is it running? On the expected port?
tasklist | findstr /i "mysql"
netstat -ano | findstr 3308

:: Stop
taskkill /FI "WindowTitle eq XamppMySQLD*" /T /F

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM