关于mysql:MacBook安装Mysql

51次阅读

共计 2251 个字符,预计需要花费 6 分钟才能阅读完成。

MacBook 装置 Mysql

Mysql 官网下载地址: https://dev.mysql.com/downloa…

官网下载 MySQL Community Server 社区版
抉择对应的版本和零碎下载: mysql-5.7.22-macos10.13-x86_64.dmg
点击装置 留神装置过程会弹出 明码 须要记住明码
在设置里最上面找到 mysql 关上后启动,这里我把开机主动启动给去掉了

#Mysql 命令增加到环境变量里
vim ~/.zshrc 
#最初退出 
export MYSQL_HOME=/usr/local/mysql
export PATH=$MYSQL_HOME/bin:$PATH

#使配置失效 
source ~/.zshrc

#查看 mysql 版本
mysql —version

#批改明码
mysql -u root -p
#输出之前保留的明码

#设置新密码 如:123456
SET PASSWORD FOR 'root'@'localhost'=PASSWORD('123456');

#设置近程连贯受权
grant all privileges on *.* to 'root'@'%' identified by '123456';

flush privileges;

#批改 mysql 配置  查看编码
show variables like '%char%';

#新版本的 mysql 装置目录下没有默认配置文件了 /usr/local/mysql/support-files  能够从其余中央复制一份过去

mysql 配置文件

sudo vim /etc/my.cnf
#查看配置
cat my.cnf

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[client]
default-character-set = utf8mb4

[mysql]
default-character-set = utf8mb4

[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET  NAMES utf8mb4'

basedir = /data/soft/mysql-5.7.16
datadir = /data/datas/mysql/data

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....

port = 3306
server_id = 212
binlog-ignore-db = mysql,sys,information_schema,performance_schema
log-bin = mysql-bin

max_binlog_size = 500M
binlog_cache_size = 2M
max_binlog_cache_size = 4M
expire_logs_days = 30
max_connections = 500
max_connect_errors = 10000
table_open_cache = 256
long_query_time = 1
slow-query-log
slow_query_log_file = /data/datas/mysql/data/slow_query_log_file.log

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

#timezone='UTC'

#批改完后重启 mysql 服务
#再次查看编码
show variables like '%char%';

正文完
 0