Mac下MySQL配置文件是my.cnf,不是my.ini

1、Mac中配置文件是my.cnf,不是my.ini,但MySQL安装后默认没有my.cnf文件,如果想配置该文件可以参考如下内容:

1)在终端输入cd /etc,进入/etc文件夹下,然后在/etc新建my.cnf文件,使用命令:sudo vim my.cnf

2、将如下配置内容写入到文件中

[client]
default-character-set=utf8
#password   = your_password
port        = 3306
socket      = /tmp/mysql.sock
[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'
#skip-networking   
log-bin=mysql-bin
binlog_format=mixed
server-id = 1
# server-id = 2
# The replication master for this slave - required
#master-host = 
# The username the slave will use for authentication when connecting
# to the master - required
#master-user = 
# The password the slave will authenticate with when connecting to
# the master - required
#master-password = 
# The port the master is listening on.
# optional - defaults to 3306
#master-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
  1. 保存my.cnf文件命令:":wq!"

  2. 修改my.cnf的文件权限:sudo chmod 664 /etc/my.cnf

  3. 重新启动mysql后,配置文件就可以生成了

你可能感兴趣的:(Mac下MySQL配置文件是my.cnf,不是my.ini)