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/mysqlexport PATH=$MYSQL_HOME/bin:$PATH#使配置失效 source ~/.zshrc#查看mysql版本mysql —version#批改明码mysql -u root -p#输出之前保留的明码#设置新密码 如:123456SET 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 = FALSEcharacter-set-server = utf8mb4collation-server = utf8mb4_unicode_ciinit_connect='SET  NAMES utf8mb4'basedir = /data/soft/mysql-5.7.16datadir = /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 = 3306server_id = 212binlog-ignore-db = mysql,sys,information_schema,performance_schemalog-bin = mysql-binmax_binlog_size = 500Mbinlog_cache_size = 2Mmax_binlog_cache_size = 4Mexpire_logs_days = 30max_connections = 500max_connect_errors = 10000table_open_cache = 256long_query_time = 1slow-query-logslow_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%';