本文为博主原创,若转载请注名出处。

在Mac上安装homebrew(官网安装教程)

homebrew依赖:Command Line Tools (CLT) for Xcode或者Xcode这两者 的安装就不细说了在准备好以上工具后在terminal输入:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

关于使用homebrew的使用在这里不做介绍

确认安装成功

在terminal输入:

brew doctor

使用homebrew安装mysql

在terminal输入:

brew install mysql

homebrew的配置

使用mysql的配置脚 本:/usr/local/opt/mysql/bin/mysql_secure_installation 启动这个脚本后,即可根据如下命令提示进行初始化设置(在这之前先启动mysql服务)

sunyichaodeMacBook-Pro:~ sunyichao$ /usr/local/opt/mysql/bin/mysql_secure_installation //mysql 提供的配置向导

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD PLUGIN can be used to test passwordsand improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: k //是否采用mysql密码安全检测插件(这里作为演示选择否,密码检查插件要求密码复杂程度高,大小写字母+数字+字符等)

Please set the password for root here. // 首次使用自带配置脚本,设置root密码

New password:

Re-enter new password:

By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment.

Remove anonymous users? [Y/n] Y //是否删除匿名用户

... Success!

Normally, root should only be allowed to connect from 'localhost'.This

ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y //是否禁止远程登录

... Success!

By default, MySQL comes with a database named 'test' that anyone can

access.This is also intended only for testing, and should be removed

before moving into a production environment.

Remove test database and access to it? [Y/n] Y //删除测试数据库,并登录

Dropping test database...

... Success!

Removing privileges on test database...

... Success!

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

Reload privilege tables now? [Y/n] Y//重新载入权限表

... Success!

All done!

接下来我们在terminal中启动mysql服务:

brew services start mysql

进入mysql命令行:

mysql -u root -p (接下来输入密码)

成功进入mysql命令行之后查看当前编码格式:

show variables like "%char%"

为了避免一些麻烦编码需要修改。我们先停掉mysql服务:

exit

brew services stop mysql

mysql的全局配置文件在my.cnf文件里面,可是问题来了,mysql5.6或者5.7安装目录下已经没有这个文件了,但是有一个my-defalut.cnf的文件.打开看看:

第二行已经告诉了我们解决问题的方法在:

http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

创建my.cnf 文件将以下内容复制进去

# Example MySQL config file for small systems.

#

# This is for a system with little memory (<= 64M) where MySQL is only used

# from time to time and it's important that the mysqld daemon

# doesn't use much resources.

#

# MySQL programs look for option files in a set of

# locations which depend on the deployment platform.

# You can copy this option file to one of those

# locations. For information about these locations, see:

# http://dev.mysql.com/doc/mysql/en/option-files.html

#

# In this file, you can use all long options that a program supports.

# If you want to know which options a program supports, run the program

# with the "--help" option.

# The following options will be passed to all MySQL clients

[client]

default-character-set=utf8

#password = your_password

port = 3306

socket = /tmp/mysql.sock

# Here follows entries for some specific programs

# The MySQL server

[mysqld]

default-storage-engine=INNODB

character-set-server=utf8

collation-server=utf8_general_ci

port = 3306

socket = /tmp/mysql.sock

skip-external-locking

key_buffer_size = 16K

max_allowed_packet = 1M

table_open_cache = 4

sort_buffer_size = 64K

read_buffer_size = 256K

read_rnd_buffer_size = 256K

net_buffer_length = 2K

thread_stack = 128K

# Don't listen on a TCP/IP port at all. This can be a security enhancement,

# if all processes that need to connect to mysqld run on the same host.

# All interaction with mysqld must be made via Unix sockets or named pipes.

# Note that using this option without enabling named pipes on Windows

# (using the "enable-named-pipe" option) will render mysqld useless!

#

#skip-networking

server-id = 1

# Uncomment the following if you want to log updates

#log-bin=mysql-bin

# binary logging format - mixed recommended

#binlog_format=mixed

# Causes updates to non-transactional engines using statement format to be

# written directly to binary log. Before using this option make sure that

# there are no dependencies between transactional and non-transactional

# tables such as in the statement INSERT INTO t_myisam SELECT * FROM

# t_innodb; otherwise, slaves may diverge from the master.

#binlog_direct_non_transactional_updates=TRUE

# Uncomment the following if you are using InnoDB tables

#innodb_data_home_dir = /usr/local/mysql/data

#innodb_data_file_path = ibdata1:10M:autoextend

#innodb_log_group_home_dir = /usr/local/mysql/data

# You can set .._buffer_pool_size up to 50 - 80 %

# of RAM but beware of setting memory usage too high

#innodb_buffer_pool_size = 16M

#innodb_additional_mem_pool_size = 2M

# Set .._log_file_size to 25 % of buffer pool size

#innodb_log_file_size = 5M

#innodb_log_buffer_size = 8M

#innodb_flush_log_at_trx_commit = 1

#innodb_lock_wait_timeout = 50

[mysqldump]

quick

max_allowed_packet = 16M

[mysql]

no-auto-rehash

# Remove the next comment character if you are not familiar with SQL

#safe-updates

[myisamchk]

key_buffer_size = 8M

sort_buffer_size = 8M

[mysqlhotcopy]

interactive-timeout

那么这个文件保存在哪里呢?

打开terminal输入:

mysql --help

你会找到:

Default options are read from the following files in the given order:

/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf

默认的设置会按下面按顺序给出来文件夹中的my.cnf文件读取所以我们就直接将my.cnf放在/etc下面(这是个隐藏文件夹在terminal中输入:defaults write com.apple.finder AppleShowAllFiles -boolean true ; killall Finder 即可显示隐藏文件,若想改回来把true改为false再次输入运行即可)

再次检查mysql编码问题:

进入mysql shell之后输入:

show variables like "%char%";

若有错误请留言告知,谢谢

homebrew下安装mysql_Mac下homebrew安装Mysql以及配置问题相关推荐

  1. mac笔记本安装mysql_mac下安装MySQL完整步骤(图文详情)

    原文摘自:http://www.jb51.net/article/103841.htm 最近使用Mac系统,准备搭建一套本地web服务器环境.因为Mac系统自带PHP和apach,但是没有自带mysq ...

  2. mac下php+mysql_Mac下Apache+MySQL+PHP安装

    max下是自带有Apache和php的服务器的,不需要另外 安装 ,本文就对相关配置进行介绍. 第一:Apache 在终端中输入,下面指令即可启动Apache服务器: //启动 sudo apache ...

  3. mac笔记本安装mysql_Mac下安装mysql5.7 完整步骤(图文详解)

    最近使用Mac系统,准备搭建一套本地web服务器环境.因为Mac系统自带PHP和apach,但是没有自带mysql,所以要手动去安装mysql,本次安装mysql最新版5.7.17. 1.官网下载 M ...

  4. brew源码安装mysql_mac使用brew安装mysql

    1.安装mysql #brew install mysql 报错 Error: The following directories are not writable by your user: /us ...

  5. mac 卸载 安装mysql_Mac 卸载与安装mysql

    卸载 1.打开系统偏好设置,点击mysql图标,stop掉mysql运行: 2.打开终端按步骤执行如下命令: (1)ps -el | grep mysqld 输入后会显示在运行的mysql相关进程,记 ...

  6. brew php mysql_MAC下用homebrew安装及配置apache、php和mysql

    我们用到php运行环境的时候总喜欢用集成包,其实在mac下,用homebrew也可以很快的安装这些东西,配置也很简单. homebrew homebrew是mac下的一个包安装管理工具,使用非常简单方 ...

  7. mac homebrew装mysql_mac系统homebrew安装mysql

    homebrew 安装 mysql homebrew 是 macOS 缺失的软件包管理器,譬如可以下载 mysql.redis.wget 等等.操作系统:macOS High Sierra Versi ...

  8. Mac系统下Homebrew的安装和使用Homebrew安装python

    这里向大家推荐一个东西,Mac下很好用的东西,叫做Homebrew.刚开始接触Mac的时候,我也没听过这个东西,但装了以后真的觉得,TMD太碉堡了. 引用一句话:Homebrew is the eas ...

  9. mac 黑窗口连接mysql_Mac下安装配置MySQL

    一 下载MySQL 访问MySQL的官网http://www.mysql.com/downloads/ 然后在页面中会看到"MySQL Community Server"下方有一个 ...

  10. mac 如何配置mysql_MAC下安装与配置MySQL

    一 下载MySQL 访问MySQL的官网http://www.mysql.com/downloads/ 然后在页面中会看到"MySQL Community Server"下方有一个 ...

最新文章

  1. Java继承_Java面试题总结(一)
  2. Windows Presentation Foundation(WPF)中的数据绑定(使用XmlDataProvider作控件绑定)
  3. MATLAB中代码优化的两种方法
  4. 在FCKeditor 2.6中添加插入视频和音频功能(最新修订版)
  5. Vista开发之旅:微软开发技术20年回顾
  6. 时间序列与R语言应用(part1)--时间序列基本概念
  7. 马斯克又要搞事情,不锈钢材质的Space X“星际飞船”正式亮相
  8. python常用类型的内置函数列表
  9. win10运行YOLOv4+OPENCV+VS2017
  10. [转载] python中的且语句_简单探讨python中的语句和语法
  11. 目标检测的图像特征提取之(一)HOG特征
  12. 在哪下拼多多上传助手?拼多多软件方法介绍
  13. 生活随记 - 75公斤重 急需减肥
  14. 分布式光伏运维服务器,户用分布式光伏电站运维指导手册——运维及安全
  15. oracle中private同义词和public同义词
  16. modbus tcp主站和从站_Modbus-RTU 一主多从PLC无线通讯经典案例
  17. 数据结构实验——顺序表操作
  18. 兄弟姐妹们,有没有啥开源的项目能加一下我吗?
  19. 「传统的互联网模式」呈现的是粗放式的,野蛮生长的状态
  20. AppScan 使用疑难解决

热门文章

  1. X3平台制程及工卡开立设计说明
  2. xadmin可能是帮助我完成django网站的一大助力
  3. dockerfile制作docker镜像
  4. HTTP和HTTPS有什么区别? 什么是SSL证书?使用ssl证书优势?
  5. 统计Linux服务器连接数
  6. 【第1章】初识MySQL
  7. Servlet做Controller,实现一个类处理多个请求
  8. 单页面应用的路由问题
  9. BZOJ1397 : Ural 1486 Equal squares
  10. 移动金库模式保护客户信息 覆盖17套关键系统