programing

MySQL my.cnf 위치를 찾으려면 어떻게 해야 합니까?

sourcejob 2022. 10. 4. 23:27
반응형

MySQL my.cnf 위치를 찾으려면 어떻게 해야 합니까?

MySQL을 요?my.cnfPHP의 PHP와 한 구성입니다.phpinfo() 위치를 알 수 있다php.ini

이를 추적하는 내부 MySQL 명령은 없습니다. 조금 추상적입니다.파일은 5(또는 그 이상)일 수 있습니다.모두 유효하게 됩니다.이것은 캐스케이딩을 로드하기 때문입니다.

  • /etc/my.cnf
  • /etc/my.cnf
  • $MYSql_HOME/my.cnf
  • [ datadir ] / my . cnf
  • ~/.my.cnf

MySQL my my my my my 。여러 개를 찾으면 각각 로드되고 값이 서로 덮어씁니다(제 생각엔 나열된 순서대로). ,,--defaults-file기본적으로 엉덩이에 큰 골칫거리죠

하지만 너무 혼란스러워서 /etc/my.cnf에 있을 가능성이 높습니다.

(값만 표시하려면 권한이 필요합니다.)


실행합니다.mysql --help뭇매를 맞다

Default options are read from the following files in the given order: /etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf

여기에 이미지 설명 입력

MySQL은 실제로 my.cnf(또는 Windows의 my.ini)를 검색하는 모든 위치의 목록을 "요구"할 수 있습니다.이것은 SQL 쿼리가 아닙니다.대신 다음 작업을 수행합니다.

$ mysqladmin --help

또는 5.7 이전 버전:

$ mysqld --help --verbose

첫 번째 줄에 my.cnf 로케이션 목록이 있는 메시지가 나타납니다.내 기계에는 다음과 같은 기능이 있습니다.

Default options are read from the following files in the given order:
/etc/my.cnf
/etc/mysql/my.cnf
/usr/etc/my.cnf
~/.my.cnf

또는 Windows의 경우:

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:\Program Files\MySQL\MySQL Server 5.5\my.ini
C:\Program Files\MySQL\MySQL Server 5.5\my.cnf

다만, 이러한 장소에는 my.cnf 파일이 없는 경우가 있습니다.따라서 MySQL 배포와 함께 제공되는 샘플 구성 파일 중 하나를 사용하여 파일을 직접 생성할 수 있습니다(Linux에서 참조)./usr/share/mysql/*.cnf하십시오. 복사해 ./etc/my.cnf

또한 my.cnf 또는 my.ini 파일에 대한 사용자 정의 경로를 정의하는 명령줄 옵션도 있습니다.예를 들어, 이것은 Windows의 MySQL 5.5의 경우입니다.이것은 데이터 디렉토리의 my.ini 파일을 가리킵니다.이 파일은 일반적으로 다음과 같이 나열되지 않습니다.mysqld --help --verbose - 이 Windows의 경우 - 서비스 속성을 참조하여 이 경우에 해당하는지 확인합니다.

마지막으로, https://dev.mysql.com/doc/refman/8.0/en/option-files.html 를 참조해 주세요.자세한 것은, 이쪽에서 설명합니다.

단말기에서 언제든지 find를 실행할 수 있습니다.

find / -name my.cnf
mysql --help | grep /my.cnf | xargs ls

의 위치를 .my.cnf는 Mac™Mac/Linux®에.

ls: cannot access '/etc/my.cnf': No such file or directory
ls: cannot access '~/.my.cnf': No such file or directory
 /etc/mysql/my.cnf

in우, in, 에다다다 in in in in에 있습니다./etc/mysql/my.cnf

ls: /etc/my.cnf: No such file or directory
ls: /etc/mysql/my.cnf: No such file or directory
ls: ~/.my.cnf: No such file or directory
/usr/local/etc/my.cnf

in우, in, 에다다다 in in in in에 있습니다./usr/local/etc/my.cnf

다음을 사용할 수 있습니다.

locate my.cnf
whereis my.cnf
find . -name my.cnf

다음과 같이 동작할 수 있습니다.

strace mysql ";" 2>&1  | grep cnf

내 기계에서 다음 출력이 다음과 같습니다.

stat64("/etc/my.cnf", 0xbf9faafc)       = -1 ENOENT (No such file or directory)
stat64("/etc/mysql/my.cnf", {st_mode=S_IFREG|0644, st_size=4271, ...}) = 0
open("/etc/mysql/my.cnf", O_RDONLY|O_LARGEFILE) = 3
read(3, "# /etc/mysql/my.cnf: The global "..., 4096) = 4096
stat64("/home/xxxxx/.my.cnf", 0xbf9faafc) = -1 ENOENT (No such file or directory)

따라서 /etc/mysql/my.cnf는 stat64()와 read()가 성공했기 때문에 /etc/mysql/my.cnf가 정상인 것 같습니다.

기본적으로는 mysql은 먼저 /etc 폴더에서 my.cnf를 검색합니다.이 폴더 내에 /etc/my.cnf 파일이 없는 경우 문서(https://dev.mysql.com/doc/refman/5.6/en/option-files.html)에 표시된 대로 이 폴더에 새 파일을 만들 것을 권장합니다.

또한 mysql 설치에서 제공된 기존 my.cnf를 검색할 수도 있습니다.다음 명령을 실행할 수 있습니다.

sudo find / -name "*.cnf"

myisam 테이블과 innodb mysql 지원 없이 다음 컨피규레이션파일을 사용할 수 있습니다(mac os x maverick의 mysql 포트 설치).이 구성 파일의 각 명령을 확인하십시오.

# Example MySQL config file for large systems.
#
# This is for a large system with memory = 512M where the system runs mainly
# MySQL.
#
# MySQL programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, see:
# http://dev.mysql.com/doc/mysql/en/option-files.html
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.

# The following options will be passed to all MySQL clients
[client]
#password   = your_password
port        = 3306
socket      = /opt/local/var/run/mysql5/mysqld.sock

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port        = 3306
socket      = /opt/local/var/run/mysql5/mysqld.sock
skip-locking
key_buffer_size = 256M
max_allowed_packet = 1M
table_open_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8

# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
# 
#skip-networking

# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin

# binary logging format - mixed recommended
binlog_format=mixed

# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id   = 1

# Replication Slave (comment out master section to use this)
#
# To configure this host as a replication slave, you can choose between
# two methods :
#
# 1) Use the CHANGE MASTER TO command (fully described in our manual) -
#    the syntax is:
#
#    CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,
#    MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
#
#    where you replace <host>, <user>, <password> by quoted strings and
#    <port> by the master's port number (3306 by default).
#
#    Example:
#
#    CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
#    MASTER_USER='joe', MASTER_PASSWORD='secret';
#
# OR
#
# 2) Set the variables below. However, in case you choose this method, then
#    start replication for the first time (even unsuccessfully, for example
#    if you mistyped the password in master-password and the slave fails to
#    connect), the slave will create a master.info file, and any later
#    change in this file to the variables' values below will be ignored and
#    overridden by the content of the master.info file, unless you shutdown
#    the slave server, delete master.info and restart the slaver server.
#    For that reason, you may want to leave the lines below untouched
#    (commented) and instead use CHANGE MASTER TO (see above)
#
# required unique id between 2 and 2^32 - 1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
#server-id       = 2
#
# The replication master for this slave - required
#master-host     =   <hostname>
#
# The username the slave will use for authentication when connecting
# to the master - required
#master-user     =   <username>
#
# The password the slave will authenticate with when connecting to
# the master - required
#master-password =   <password>
#
# The port the master is listening on.
# optional - defaults to 3306
#master-port     =  <port>
#
# binary logging - not required for slaves, but recommended
#log-bin=mysql-bin

# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /opt/local/var/db/mysql5
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = /opt/local/var/db/mysql5
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 256M
#innodb_additional_mem_pool_size = 20M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 64M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

Ubuntu 16의 경우: /etc/mysql/mysql.conf.d/mysqld.cnf

알 수 의 konyak을 장소 수 .my.cnf 실행해 줄서다mysqladmin --help이것은 매우 장황하기 때문에, 다음의 조작으로 관심 있는 부분을 신속히 참조할 수 있습니다.

$ mysqladmin --help | grep -A1 'Default options'

이것에 의해, 다음과 같은 출력이 표시됩니다.

Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf

설치 이러한 아직 하지 않을 수.mysql은 아직 존재하지 않을 수 있습니다. 하면 돼요.cat하고, 을 작성하기 .my.cnf원하는 장소에서 필요한 경우.

Linux 환경에서 MySQL을 어떻게 설정했는지 모르겠지만 확인하셨나요?

  • /etc/my.cnf

달려보세요.mysqld --help --verbose | grep my.cnf | tr " " "\n"

출력은 다음과 같습니다.

/etc/my.cnf
/etc/mysql/my.cnf
/usr/local/etc/my.cnf
~/.my.cnf

이 명령어를 실행할 수도 있습니다.

mysql --help | grep cnf

Homebrew가 설치된 Mac을 사용하는 경우

brew info mysql

뭐랄까...

$ brew info mysql
mysql: stable 5.6.13 (bottled)
http://dev.mysql.com/doc/refman/5.6/en/
Conflicts with: mariadb, mysql-cluster, percona-server
/usr/local/Cellar/mysql/5.6.13 (9381 files, 354M) *

은 " " " 입니다.INSTALLERDIR SQL 서 sql

마리아드가 비록DB는 여기에 있는 다른 응답에 나열된 다양한 my.cnf 파일에서 구성 세부 정보를 로드합니다. 또한 다른 이름을 가진 다른 파일에서 구성 세부 정보를 로드할 수도 있습니다.

즉, my.cnf 파일 중 하나를 변경하면 다른 이름의 파일이 덮어쓸 수 있습니다.변경을 고정하려면 올바른(마지막으로 로드된) 구성 파일에서 변경해야 합니다. 또는 모든 파일에서 변경해야 합니다.

그러면 로드될 수 있는 모든 구성 파일을 어떻게 찾을 수 있을까요?my.cnf 파일을 찾는 대신 다음을 실행합니다.

grep -r datadir /etc/mysql/

이렇게 하면 datadir가 언급되는 모든 장소가 검색됩니다.제 경우, 다음과 같은 답이 나옵니다.

/etc/mysql/mariadb.conf.d/50-server.cnf:datadir     = /var/lib/mysql 

이 파일(/etc/mysql/mariadb.conf.d/50-server.cnf)을 편집하여 datadir 값을 변경하면 동작하지만 my.cnf에서는 변경할 수 없습니다.따라서 어떤 옵션을 변경하고 싶은지 이 방법으로 찾아보세요.

다음 방법으로 내 것을 찾았습니다.

mysqld --help --verbose | grep my.cnf

MySQL Workbench 사용자만 응답 가능

여기에 이미지 설명 입력

또 다른 옵션은 whereis 명령어를 사용하는 것입니다.

예: my.cnf는 어디에 있습니까?

을 xampp로 설치했습니다.apache, php and mysql우분투로.거기.my.cnf, 라고 되어 있습니다./opt/lampp/etc/도움이 됐으면 좋겠는데

모든 훌륭한 제안들이요, 제 경우엔 그 장소들 중 어느 곳에서도 찾을 수 있는 건/usr/share/mysql RHEL VM을 mysql5.5

MySQL 버전에 따라 다양한 위치를 확인해야 합니다.

mysqld --help -verbose | grep my.cnf

For Homebrew:
/usr/local/Cellar/mysql/8.0.11/bin/mysqld (mysqld 8.0.11)

Default possible locations:
/etc/my.cnf
/etc/mysql/my.cnf
~/.my.cnf

Found mine here: 
/usr/local/etc/my.cnf

상에 (5것, 8의 이되어 있는 , Debian/Ubuntu를 은 Mysql 입니다..cnf찾은 파일은 다음과 같습니다.

sudo update-alternatives --config my.cnf

다음과 같은 출력이 표시됩니다.

There are 3 choices for the alternative my.cnf (providing /etc/mysql/my.cnf).

  Selection    Path                        Priority   Status
------------------------------------------------------------
  0            /etc/mysql/mariadb.cnf       500       auto mode
  1            /etc/mysql/mariadb.cnf       500       manual mode
  2            /etc/mysql/my.cnf.fallback   100       manual mode
* 3            /etc/mysql/mysql.cnf         300       manual mode

로 되어 있어요./etc/mysql/mysql.cnf다음 사항에 주의를 기울이는 것이 합리적입니다.

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

MySQL을 합니다..cnf/etc/mysql/conf.d/ 있는 모든 이 표시됩니다/etc/mysql/mysql.conf.d/

해피 튜닝!

Ubuntu(직접 편집):

$ sudo nano /etc/mysql.conf.d/mysqld.cnf

VPS에서 이미 실행 중인 서버에서 my.cnf를 편집하려고 할 경우 다음을 시도해 보십시오.

ps aux | grep mysql

와 mysql 명령어가 실행되고 있는 됩니다.--defaults-file

MySQL/MariaDB를 사용합니다." " 가 없는 --defaults-file 이 는 .하고 있을 이 있습니다은 .cnf에되어 있습니다.mysqladmin --help남들이 지적한 바와 같이

my.cnf 또는 기타 파일은 find 명령으로 찾을 수 있습니다.

find / -name my.cnf (or any other file name)
  1. find는 명령어입니다.
  2. /(경로)는 경로입니다.
  3. my.cnf는 파일 이름입니다.

MAMP를 사용하는 경우 [Templates]> [ MySQL ( my . cnf ) ]> [ version ]에 접속합니다.

MAMP 창을 사용하지 않는 경우 [Customize]버튼을 사용하여 툴바를 커스터마이즈해야 할 수 있습니다.

MAMP PRO 템플릿메뉴

저는 "ENGINE=MyISAM" 종류의 테이블을 가지고 있었는데, "ENGINE=InnoDB"로 바꾸면 작동했습니다. :) Azure App Service의 PhpMyAdmin에서:)

액세스 권한에 따라 다르지만, 이 작업은 phpmyadmin sql 콘솔에서 수행합니다.

변수 표시

그런 다음 다음 변수를 변경할 수 있습니다.

SET GLOBAL max_connections = 1000;

또는

SET @@GLOBAL.max_connections = 1000;

시험삼아니다

MySQL 구성 파일:

/etc/my.cnf

해라

mysql --verbose --help | grep -A 1 "Default options"

Ubuntu 20.04.4 LTS(Focal Fossa)MariaDB 10.5의 경우:

# The MariaDB configuration file
#
# The MariaDB/MySQL tools read configuration files in the following order:
# 0. "/etc/mysql/my.cnf" symlinks to this file, reason why all the rest is read.
# 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults,
# 2. "/etc/mysql/conf.d/*.cnf" to set global options.
# 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
# 4. "~/.my.cnf" to set user-specific options.
#
# If the same option is defined multiple times, the last one will apply.

언급URL : https://stackoverflow.com/questions/2482234/how-do-i-find-the-mysql-my-cnf-location

반응형