Install mysql on Mac
Typer | Posted on | |
# 安装最新版 MySQL(默认是 9.x)
brew install mysql
# 启动 MySQL 服务
brew services start mysql
# 初始化安全设置(设置 root 密码)
mysql_secure_installation
• 是否启用密码验证插件 → 按 n(方便设置简单密码)
• 设置 root 密码 → 输入 1122
• Remove anonymous users? → y
• Disallow root login remotely? → y
• Remove test database? → y
• Reload privilege tables now? → y
# create database;
CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
# run mysql
mysql -u root -p
# login without input password by create configration files
sudo vim ~/.my.cnf
[client]
user=root
password=test
socket=/opt/homebrew/var/mysql/mysql.sock