一、MySQL的安装

  从官网(https://dev.mysql.com/downloads/mysql/)中下载Mac OS X 10.12 (x86, 64-bit), DMG Archive(mysql-5.7.19-macos10.12-x86_64.dmg)版,双击按提示安装,安装完成后可在控制面板下启动关闭MySQL服务器,

  同时安装客户端:MySQL Workbench.app,(下载链接:https://dev.mysql.com/downloads/file/?id=468289)

  启动MySQL服务器,打开MySQL Workbench,输入初始密码,随即提示修改初始密码。

二、设置Terminal下登录路径:

  在/Users/**/新建文件:.bash_profile

  文件中输入:

export PATH=${PATH}:/usr/local/mysql/bin

   

  保存即可。在Terminal下,即可使用"mysql -u root -p"进行登录。

三、数据库编码问题

在Terminal中登录MySQL客户端(mysql -u root -p)查看数据库编码,命令如下:

mysql> SHOW VARIABLES LIKE 'char%';

  发现

character_set_database | latin1

character_set_server | latin1

  需要进行编码设置,但安装文件里无my.cnf文件,网上很多解决方法都没用,只能自建my.cnf文件。

  关闭MySQL服务器,使用MacVim创建my.cnf,输入内容为:

# Example MySQL config file for medium systems.
#
# This is for a system with little memory (32M - 64M) where MySQL plays
# an important part, or systems up to 128M where MySQL is used together with
# other programs (such as a web server)
#
# 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 =
socket = /tmp/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
character-set-server=utf8
init_connect='SET NAMES utf8
port =
socket = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache =
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
character-set-server=utf8
init_connect='SET NAMES utf8'
# 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
# (via the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking # Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin # binary logging format - mixed recommended
binlog_format=mixed # required unique id between and ^ -
# defaults to if master-host is not set
# but will not function as a master if omitted
server-id = # Replication Slave (comment out master section to use this)
#
# To configure this host as a replication slave, you can choose between
# two methods :
#
# ) Use the CHANGE MASTER TO command (fully described in our manual) -
# the syntax is:
#
# CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,
# MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
#
# where you replace <host>, <user>, <password> by quoted strings and
# <port> by the master's port number (3306 by default).
#
# Example:
#
# CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=,
# MASTER_USER='joe', MASTER_PASSWORD='secret';
#
# OR
#
# ) Set the variables below. However, in case you choose this method, then
# start replication for the first time (even unsuccessfully, for example
# if you mistyped the password in master-password and the slave fails to
# connect), the slave will create a master.info file, and any later
# change in this file to the variables' values below will be ignored and
# overridden by the content of the master.info file, unless you shutdown
# the slave server, delete master.info and restart the slaver server.
# For that reason, you may want to leave the lines below untouched
# (commented) and instead use CHANGE MASTER TO (see above)
#
# required unique id between and ^ -
# (and different from the master)
# defaults to if master-host is set
# but will not function as a slave if omitted
#server-id =
#
# The replication master for this slave - required
#master-host = <hostname>
#
# The username the slave will use for authentication when connecting
# to the master - required
#master-user = <username>
#
# The password the slave will authenticate with when connecting to
# the master - required
#master-password = <password>
#
# The port the master is listening on.
# optional - defaults to
#master-port = <port>
#
# binary logging - not required for slaves, but recommended
#log-bin=mysql-bin # 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 - %
# 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 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit =
#innodb_lock_wait_timeout = [mysqldump]
quick
max_allowed_packet = 16M [mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
default-character-set=utf8 [myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M [mysqlhotcopy]
interactive-timeout

    保存并将文件存在至/etc/目录之下,重启mysql服务器,即修改成功,

如果还是不能插入汉字,请重新创建数据库和表。

参考:http://www.jianshu.com/p/628bcf8bb557

MySQL安装再折腾--编码的设置的更多相关文章

  1. MySQL基础配置之mysql的默认字符编码的设置(my.ini设置字符编码) - 转载

    MySQL基础配置之mysql的默认字符编码的设置(my.ini设置字符编码) MySQL的默认编码是Latin1,不支持中文,那么如何修改MySQL的默认编码呢,下面以设置UTF-8为例来说明. 需 ...

  2. MySQL基础配置之mysql的默认字符编码的设置(my.ini设置字符编码)

    MySQL基础配置之mysql的默认字符编码的设置(my.ini设置字符编码) MySQL的默认编码是Latin1,不支持中文,那么如何修改MySQL的默认编码呢,下面以设置UTF-8为例来说明. 需 ...

  3. mysql 安装和修改编码(utf8mb4)

    安装mysql(linux 我的环境centos 7) 安装MySQL官方的Yum Repository wget -i -c http://dev.mysql.com/get/mysql57-com ...

  4. Mysql安装与设置用户名、密码

    个人博客网:https://wushaopei.github.io/    (你想要这里多有) 关于MySQL程序中数据库调度的流程图解: ​ 1-MySql数据库的安装 ​ 安装前要注意,看看当前系 ...

  5. mysql安装 卸载 查字符集编码

    下载地址 :     https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.11-winx64.zip 解压zip  解压完之后的目录 在里面新建一 ...

  6. 数据库 MySQL安装图解

    MySQL安装图解 一.MYSQL的安装 1.打开下载的mysql安装文件,双击运行mysql-5.5.40-win32.msi. 2.选择安装类型,有"Typical(默认)". ...

  7. MySQL安装图解

    MySQL安装图解 打开下载的mysql安装文件mysql-5.0.27-win32.zip,双击解压缩,运行“setup.exe”,出现如下界面:           mysql安装向导启动,按“N ...

  8. Windown安装Mysql安装图解

    一.MYSQL的安装 1.打开下载的mysql安装文件mysql-5.0.27-win32.zip,双击解压缩,运行“setup.exe”. 2.选择安装类型,有“Typical(默认)”.“Comp ...

  9. 数据库-MYSQL安装配置和删除

    * 课程回顾: * 完成注册和登陆的功能. * 准备的工作 * 技术.开源jar包 * 开发的功能使用MVC模式 * C:控制层(接收请求和从客户端发送过来的参数) * 接收参数(request对象) ...

随机推荐

  1. MQ 消息队列的比较

    目前业界有很多MQ产品,我们作如下对比: RabbitMQ 是使用Erlang编写的一个开源的消息队列,本身支持很多的协议:AMQP,XMPP, SMTP, STOMP,也正是如此,使的它变的非常重量 ...

  2. ArrayList 和 Vector 的区别

    这两个类都实现了 List 接口( List 接口继承了 Collection 接口),他们都是有序集合,即存储在这两个集合中的元素的位置都是有顺序的,相当于一种动态的数组,我们以后可以按位置索引号取 ...

  3. php pdo prepare真的安全吗

    详见 这里 Let's say I have code like this: $dbh = new PDO("blahblah"); $stmt = $dbh->prepar ...

  4. P2278 操作系统

    P2278 操作系统 题目描述 写一个程序来模拟操作系统的进程调度.假设该系统只有一个CPU,每一个进程的到达时间,执行时间和运行优先级都是已知的.其中运行优先级用自然数表示,数字越大,则优先级越高. ...

  5. 利用atimicInteger cas的特性实现一个锁

    利用atimicInteger cas的特性实现一个锁 主要是使用的是 atomicIntegerAPI 的compareAndSet()方法,让线程不在阻塞,获取不到直接失败. 我们先定义一个异常类 ...

  6. Mac 10.12常用软件清单

    链接: https://pan.baidu.com/s/1slds1OD 密码: 7m5t 配套教程:http://www.cnblogs.com/EasonJim/tag/mac/ 如果失效了,联系 ...

  7. Mac OS 10.12使用U盘重装(转)

    OS X Capitan和macOS Sierra的安装方式和下载系统的方法都是一致的,下面是OS X Capitan的安装方法: 一.准备工作: 准备一个8GB或者8G以上容量的U盘 确保里面的数据 ...

  8. WCF系列教程之WCF服务配置

    文本参考自:http://www.cnblogs.com/wangweimutou/p/4365260.html 简介:WCF作为分布式开发的基础框架,在定义服务以及消费服务的客户端时可以通过配置文件 ...

  9. 【开源组件】FastDFS极速入门与安装

    FastDFS是一个开源的轻量级的分布式文件系统,为互联网量身定制,充分考虑了冗余备份.负载均衡.线性扩容等机制,并注重高可用.高性能等指标,使用FastDFS很容易搭建一套高性能的文件服务器集群提供 ...

  10. ORA-04091: table xxx is mutating, trigger/function may not see it

    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 Connected as tbcs SQL> SQL ...