赞
踩
系统:macOS Ventura
芯片:M2
数据库:MySQL 8.0.33
官网地址:https://www.mysql.com/
点击页签“DOWLOADS“后将页面拖到底部,点MySQL Community Server。
按照向导操作即可
cd /etc/paths.d
vim .bash_profile
输入下面的内容:
export PATH=$PATH:/usr/local/mysql/bin
export PATH=$PATH:/usr/local/mysql/support-files
然后执行配置文件使其生效:
source ./.bash_profile
查看数据库的状态:
sudo mysql.server status
会报错,提示 pid 文件找不到。
查看原因:
打开macbook pro 的系统偏好,在底部找到已经安装的数据库。
接着点击页签configuration,找到错误日志文件的路径。
查看日志文件:
sudo tail /usr/local/mysql/data/mysqld.local.err
看文件末尾最新的日志,可以大致知道是因为变量 server_id的配置问题,而这个变量是在某个.cnf文件中配置的,我不知道默认的.cnf文件在哪个目录下,但是可以在 /etc/ 下面创建一个名为 my.cnf的文件来取代默认的,文件内容如下:
# The MySQL database server configuration file. # # You can copy this to one of: # - "/etc/mysql/my.cnf" to set global options, # - "~/.my.cnf" to set user-specific options. # # One can use all long options that the program supports. # Run program with --help to get a list of available options and with # --print-defaults to see which it would actually understand and use. # # For explanations see # http://dev.mysql.com/doc/mysql/en/server-system-variables.html [mysqld] # # * Basic Settings # user = mysql pid-file = /usr/local/mysql/data/mysqld.local.pid socket = /tmp/mysql.sock port = 3306 basedir = /usr/local/mysql datadir = /usr/local/mysql/data tmpdir = /tmp lc-messages-dir = /usr/local/mysql/share log-error = /usr/local/mysql/data/mysqld.local.err pid-file = /usr/local/mysql/data/mysqld.local.pid # Recommended in standard MySQL setup sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES # # * Character sets # collation-server = utf8mb4_unicode_ci init-connect='SET NAMES utf8mb4' character-set-server = utf8mb4 # # * MyISAM # # This replaces the startup script and checks MyISAM tables if needed # the first time they are touched. On error, make copy and try a repair. myisam_recover_options = BACKUP # # * NDB Cluster # # See /usr/local/mysql/bin/ndbd # Note: ndbd init script requires this to include nodeid! # datadir=/usr/local/mysql/data # [MYSQL_CLUSTER] # ndb-connectstring=127.0.0.1 [mysqld_safe] log-error = /usr/local/mysql/data/mysqld.local.err pid-file = /usr/local/mysql/data/mysqld.local.pid # # * InnoDB # # InnoDB is enabled by default with a 10MB datafile in /usr/local/mysql/data/. # Read the manual for more InnoDB related options. There are many! innodb_buffer_pool_size = 128M [client] port = 3306 socket = /tmp/mysql.sock
其中的变量 log-error、pid-file、basedir、datadir的值可以从MySQL的配置界面中获得。
配置好之后,再启动数据库,具体参见这里:https://liaowenxiong.blog.csdn.net/article/details/121136723。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。