在Mac上安裝MySQL后,需要進行一些配置,其中my.ini文件是重要的一部分。my.ini是MySQL服務器的配置文件。它可以設置MySQL服務器的常規(guī)設置、存儲引擎設置、日志設置等等。下面將介紹如何在Mac上配置my.ini文件。
首先,在Terminal中運行以下命令打開my.cnf文件:
sudo nano /etc/my.cnf
然后,在my.cnf文件中找到以下設置:
[mysqld_safe] socket = /var/lib/mysql/mysql.sock [mysqld] socket = /var/lib/mysql/mysql.sock datadir = /usr/local/mysql/data # Default to using old password format for compatibility with mysql 3.x # clients (those using the mysqlclient10 compatibility package). old_passwords=1 # Disabling symbolic-links is recommended to prevent assorted security risks; # to do so, uncomment this line: # symbolic-links=0 key_buffer_size = 256M max_allowed_packet = 64M # Enable query caching query_cache_type = 1 query_cache_size = 64M query_cache_limit = 2M join_buffer_size=256K tmp_table_size=64M max_heap_table_size=64M thread_cache_size=4 innodb_buffer_pool_size=128M innodb_additional_mem_pool_size=20M innodb_flush_log_at_trx_commit=1 innodb_lock_wait_timeout=50 innodb_file_per_table=1 [mysqldump] quick max_allowed_packet = 32M [mysql] no-auto-rehash # Remove the next comment character if you are not familiar with SQL #safe-updates [isamchk] key_buffer = 8M sort_buffer_size = 8M [myisamchk] key_buffer = 8M sort_buffer_size = 8M [mysqlhotcopy] interactive-timeout
在這里設置了socket位置、datadir(數(shù)據(jù)目錄),以及一些其他設置,根據(jù)需要進行更改。
如果需要在運行mysql_upgrade命令時避免警告信息,需要將my.cnf文件中的以下配置打開:
# For MySQL 5.7.x and up sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES # For MySQL 5.6.x and down sql_mode=NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER
接下來,重新啟動MySQL以使用新的配置:
sudo /usr/local/mysql/support-files/mysql.server restart
這樣,Mac上的my.ini文件就配置完成了。