1,在 /etc 新建 my.cnf 文件
sudo vim my.cnf
2,将如下配置内容写入到文件中
# Example MySQL config file for medium systems.
#
# This is for a system with little memory (32M - 64M) where MySQL plays
# an important part, or systems up to 128M where MySQL is used together with
# other programs (such as a web server)
#
# 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]
default-character-set=utf8
#password = your_password
port = 3306
socket = /tmp/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
character-set-server=utf8
init_connect='SET NAMES utf8
port = 3306
socket = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
character-set-server=utf8
init_connect='SET NAMES utf8'
# 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 = /usr/local/mysql/data
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = /usr/local/mysql/data
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#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
default-character-set=utf8
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
3,设置权限
sudo chmod 664 /etc/my.cnf
4,重启mysql
系统偏好设置-> MySQL 重新启动
分享到:
相关推荐
无论是homebrew等方式,在Mac下都是不会生成my.cnf文件,因为已经使用了最优默认值,如果需要也可以自行新建或配置/etc/my.cnf 加载my.cnf位置顺序查看: mysql --verbose --help | grep my.cnf 默认安装位置:/...
在Mac OS X系统中,配置文件的位置在/usr/local/mysql/support-files/目录下,文件名为my-default.cnf。在Linux系统中,配置文件的位置可能在/etc/或/usr/local/etc/目录下,文件名为my.cnf。 查看当前配置文件 ...
其次,对于在Mac上配置`my.cnf`文件的情况,由于MySQL的安装方式不同,可能不会自动创建这个配置文件。你可以通过以下步骤来确定和创建`my.cnf`: 1. 使用命令`mysql --verbose --help | grep my.cnf`来查找MySQL...
通过修改macOS系统下MySQL的my.cnf配置文件,我们可以有效地解决中文乱码的问题。关键在于正确设置字符集和校对规则,确保客户端、服务器以及数据存储都使用统一的UTF-8编码。这样不仅解决了当前的乱码问题,也为...
mac 终端出现 ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (61) 终端 cnf 配置
接下来,我们可能需要配置MySQL的配置文件,通常位于`/etc/mysql/my.cnf`(Linux)或`C:\ProgramData\MySQL\MySQL Server X.Y\my.ini`(Windows)。这里可以调整诸如最大连接数、内存使用、日志记录等参数。 为了...
- 找到MySQL的配置文件,通常是`/etc/my.cnf`或`/usr/local/etc/my.cnf`。 - 使用文本编辑器(如vi或nano)编辑该文件,添加或修改配置选项,例如调整内存使用、日志设置等。 5. **连接与管理MySQL** 可以使用...
11. **性能优化**:学习调整MySQL配置文件(如my.cnf),优化内存使用、日志设置、查询缓存等,提升数据库性能。 12. **学习SQL语言**:掌握基本的SQL语句,如SELECT、INSERT、UPDATE、DELETE,以及更高级的JOIN、...
主要的配置文件是`my.cnf`,通常位于`/etc/my.cnf`或`C:\ProgramData\MySQL\MySQL Server x.x\my.ini`。在这个文件中,你可以修改端口号、数据存储位置、最大连接数等参数。 **4. 初始化数据库** 首次安装后,需要...
1. **修改my.cnf配置文件** my.cnf是MySQL的配置文件,位于/etc/my.cnf(Linux)或C:\ProgramData\MySQL\MySQL Server x.x\my.ini(Windows)。可以根据需要调整如内存使用、端口设置、日志文件位置等参数。 2. **...
1. 修改配置文件:在Windows中,配置文件通常为my.ini,在Linux中为my.cnf。可以在这里设置数据库路径、端口、字符集等参数。 2. 配置远程访问:如果需要远程连接MySQL,需要在my.cnf文件的[mysqld]部分添加`bind-...
2. 修改MySQL配置:你也可以选择在MySQL的配置文件(通常是`my.cnf`或`my.ini`)中,将`socket`参数设置为与PHP配置文件中相同的值,即`/var/mysql/mysql.sock`,然后重启MySQL服务。 在进行这些修改之前,务必确保...
- 配置MySQL服务器,修改`my.cnf`配置文件以设置必要的参数,如端口、用户和密码。 - 启动MySQL服务,使用`bin/mysqld_safe --user=mysql &`命令。 3. **安全设置**: - 在首次启动时,执行`bin/mysql_secure_...
MySQL的主要配置文件是my.cnf或my.ini,位于安装目录下的etc子目录。在此文件中,可以调整各种性能参数,如max_connections(最大连接数)、innodb_buffer_pool_size(InnoDB缓冲池大小)等,以适应不同的系统需求。...
1. **配置文件**:MySQL的配置主要通过修改my.cnf文件实现。这个文件通常位于/etc/my.cnf(Linux)或C:\ProgramData\MySQL\MySQL Server x.x\my.ini(Windows)。 2. **参数调整**:配置文件中包含许多参数,例如`...
1. **修改配置文件**:MySQL的配置主要通过my.cnf文件进行,该文件通常位于`/etc/my.cnf`(Linux)或`C:\ProgramData\MySQL\MySQL Server 5.6\my.ini`(Windows)。打开这个文件,你可以根据需求调整各种参数。 2. ...
- **性能优化**:可以通过调整MySQL的配置文件(my.cnf或my.ini),以及优化SQL查询语句等方式来提升数据库性能。 通过以上教程,您应该能够顺利完成MySQL在Windows操作系统的安装与配置工作。随着实践的深入,还...