简体   繁体   English

XAMPP for Windows 中 mysql 客户端“.my.cnf”的位置是什么?

[英]What is the location of mysql client ".my.cnf" in XAMPP for Windows?

What is the location of mysql client .my.cnf using XAMPP in Windows?在 Windows 中使用 XAMPP 的 mysql 客户端.my.cnf的位置是什么?

Clarification : This file does not exist by default, so when you create it, where should you place it, in order for the command line client to read it automatically?澄清:这个文件默认是不存在的,所以当你创建它时,你应该把它放在哪里,以便命令行客户端自动读取它?

Type this:输入:

mysql --help 

Then look at the output.然后看输出。 There is a block of text about 3/4 the way down describing what files it finds its defaults .my.cnf from.大约 3/4 处的文本块描述了它从哪些文件中找到其默认值.my.cnf Here is an example from XAMPP v3.2.1 :这是来自XAMPP v3.2.1示例

Default options are read from the following files in the given order:
C:\Windows\my.ini C:\Windows\my.cnf C:\my.ini C:\my.cnf C:\xampp\mysql\my.ini C:\xampp\mysql\my.cnf C:\xampp\mysql\bin\my.ini C:\xampp\mysql\bin\my.cnf

Your setup may differ.您的设置可能有所不同。 You will have to run the command to check the actual paths on your particular system.您必须运行该命令来检查特定系统上的实际路径。

Look in the MySQL config file C:\\xampp\\mysql\\bin\\my.ini .查看 MySQL 配置文件C:\\xampp\\mysql\\bin\\my.ini

At the top of that file are some comments:该文件的顶部是一些注释:

# You can copy this file to
# C:/xampp/mysql/bin/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is C:/xampp/mysql/data) or
# ~/.my.cnf to set user-specific options.

There it tells you where to find your .my.cnf file.它会告诉您在哪里可以找到您的.my.cnf文件。

After checking the default locations on Win7 with mysql --help and unable to find any config file, I manually searched for my.ini and found it at C:\\ProgramData\\MySQL\\MySQL Server xy (yep, ProgramData , not Program Files ).在使用mysql --help检查 Win7 上的默认位置并找不到任何配置文件后,我手动搜索 my.ini 并在C:\\ProgramData\\MySQL\\MySQL Server xy找到它(是的, ProgramData ,而不是Program Files ) .

Though I used an own my.ini at Program Files , the other configuration overwrote my settings.虽然我在Program Files使用了自己的 my.ini ,但其他配置覆盖了我的设置。

Go to control panel → services, look for MySQL and right click choose properties.转到控制面板 → 服务,查找 MySQL 并右键单击选择属性。 If there, in “path to EXE file”, there is a parameter like如果有,在“EXE文件的路径”中,有一个参数,如

--defaults-file="X:\\path\\to\\my.ini"

this is the file the server actually uses (independent of what mysql --help prints).这是服务器实际使用的文件(与mysql --help打印的内容无关)。

使用 XAMPP 控制面板,单击 MySQL 的 Config 按钮,您将找到它当前正在使用的文件。

It's usually in your MySQL installation folder like in C:\\Program Files\\MySQL\\MySQL Server 5.5\\my.ini or C:\\xampp\\mysql\\bin它通常位于您的 MySQL 安装文件夹中,例如C:\\Program Files\\MySQL\\MySQL Server 5.5\\my.iniC:\\xampp\\mysql\\bin

If it's not there, it's highly possible that you have none, and that MySQL is just loading default values.如果它不存在,很可能你没有,而且 MySQL 只是加载默认值。

You might have to enable hidden Files and Folders to see it.您可能必须启用隐藏的文件和文件夹才能看到它。 Go to Folder Options: in any folder, go to the top horizontal main text menu >> Tools >> Folder Options.转到文件夹选项:在任何文件夹中,转到顶部水平主文本菜单 >> 工具 >> 文件夹选项。 Enable 'View Hidden Files and Folders', and 'View Protected System Files', save & exit启用“查看隐藏文件和文件夹”和“查看受保护的系统文件”,保存并退出

XAMPP uses a file called mysql_start.bat to start MySQL and if you open that file with a text editor you can see what config file is trying to use, in the current version it is: XAMPP 使用一个名为 mysql_start.bat 的文件来启动 MySQL,如果您使用文本编辑器打开该文件,您可以看到正在尝试使用的配置文件,在当前版本中它是:

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

If you installed XAMPP on the default path it means it is on c:/xampp/mysql/bin/my.ini如果您在默认路径上安装了 XAMPP,则意味着它位于c:/xampp/mysql/bin/my.ini


If somehow the file doesn't exist you should open a console terminal (start-> type "cmd", press enter) and then write "mysql --help" and it prints a text mentioning the default locations, in the current version of XAMPP is:如果不知何故该文件不存在,您应该打开一个控制台终端(开始-> 键入“cmd”,按回车键),然后写入“mysql --help”并在当前版本中打印一个提及默认位置的文本XAMPP 是:

C:\Windows\my.ini C:\Windows\my.cnf C:\my.ini C:\my.cnf C:\xampp\mysql\my.ini C:\xampp\mysql\my.cnf

如果您使用 MySQL Workbench 连接到服务器,请在左侧菜单中添加查看“管理”和“选项文件”,则该服务器正在使用的配置文件的位置将显示在右侧窗格的底部.

在文件夹c:\\xampp\\mysql自己创建它。

On Windows you can open a command window and type the command在 Windows 上,您可以打开命令窗口并键入命令

sc qc mysql

Or:或者:

sc qc mariadb

which (depending on your flavor and version) will output something like:其中(取决于您的风格和版本)将输出如下内容:

[SC] QueryServiceConfig SUCCESS

SERVICE_NAME: mariadb
        TYPE               : 10  WIN32_OWN_PROCESS 
        START_TYPE         : 2   AUTO_START
        ERROR_CONTROL      : 1   NORMAL
        BINARY_PATH_NAME   : "C:\Program Files\MariaDB 10.4\bin\mysqld.exe" "--defaults-file=C:\Program Files\MariaDB 10.4\data\my.ini" "MariaDB"
        LOAD_ORDER_GROUP   : 
        TAG                : 0
        DISPLAY_NAME       : MariaDB
        DEPENDENCIES       : 
        SERVICE_START_NAME : NT AUTHORITY\NetworkService

From this you can see the location of the my.ini file.从中您可以看到 my.ini 文件的位置。

You can also change it with the same "sc" command like this:您也可以使用相同的“sc”命令更改它,如下所示:

sc config mysql binPath= <binary path>

Or:或者:

sc config mariadb binPath= <binary path>

For example:例如:

sc config mariadb binpath= "\"C:\Program Files\MariaDB 10.4\bin\mysqld.exe\" \"--defaults-file=M:\data\my.ini\" \"MariaDB\""

Apologize for resurrect this thread, but for Windows 8.x users can find my.cnf at this folder:为复活此线程而道歉,但对于 Windows 8.x 用户可以在此文件夹中找到 my.cnf:

C:\ProgramData\MySQL\MySQL Server 5.6\my.ini

Then also can find data folder on same folder.然后也可以在同一文件夹中找到数据文件夹。

如果您使用 Cygwin,此命令将显示位置:

mysql --help |grep -A1 Default|grep my

I don't have XAMPP installed, but the question I did end up at when I couldn't find the my.cnf or my.ini ( I can not find my.cnf on my windows computer ) was closed, and led here.我没有安装 XAMPP,但是当我找不到 my.cnf 或 my.ini( 我在 Windows 计算机上找不到 my.cnf )时,我最终提出的问题已关闭,并被引导到这里。

So - If you've installed MariaDB on Windows, and followed Windows best practices to load data somewhere OTHER than \\program files - in my case on a "d:" drive, then your my.ini will be located where you put your "data" directory.所以 - 如果您已经在 Windows 上安装了 MariaDB,并遵循 Windows 最佳实践将数据加载到\\program files以外的其他地方 - 在我的情况下是在“d:”驱动器上,那么您的my.ini将位于您放置“的位置”数据”目录。

如果您直接使用 Windows 2008 服务器上的社区安装程序安装它,它将驻留在 c:\\ProgamData\\MySql\\MysqlServerVersion\\my.ini

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

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