您的位置:首页 > 数据库 > MySQL

mysql5.6版本安装步骤详解

2015-12-17 19:16 876 查看
mysql5.0之后的版本与之前的版本有一些区别,我们在安装的时候如果用安装老版本的方法会遇到各种问题,其中最主要的区别就是配置文件my.cnf

详细安装步骤这里就不多说了,与老版本的安装步骤一样的,如有需要可以参考笔者另外一篇博文

这里主要讲解配置文件的不同之处,我们在安装过程中,到了要拷贝配置文件的那一步会遇到错误,我们会发现在目录/usr/local/mysql/support-files/(该路径可以自己定义)下没有my_large.cnf这个配置文件,只有my.cnf或者my-default.cnf,而且其中的内容又与我们原来使用的my_large.cnf很不一样,那么怎么办呢?

下面来看看我的配置文件内容:

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqld]
user=mysql
# 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 = /usr/local/mysql
datadir = /data/mysql
port = 3306
# server_id = .....
# socket = .....
character-set-server=utf8
init_connect='SET NAMES utf8'
# 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

原来的配置文件中基本只有被注释的内容,我们需要自己去手动修改。默认情况下,mysql建立数据库和表时使用的编码为latin1,不能使用中文,需要修改配置文件my.cnf。

在my.cnf下找到[client]模块,
添加如下文字:
default-character-set=utf8

在my.cnf下找到[mysql]模块,
添加如下文字:
default-character-set=utf8

在my.cnf下找到[mysqld]模块,
添加如下文字:
character-server-set=utf8
init_connect=utf8

注意上述必须是character-server-set=utf8,不能是default-character-set=utf8,否则会出错。

最重要的是其中目录和端口的设置,这几行原来是被注释掉的,我们需要将注释去掉,加上我们自定义的内容,还要在mysqld模块中指定我们数据库的属主。

本文出自 “奇迹的少年” 博客,请务必保留此出处http://raffaelexr.blog.51cto.com/8555551/1725794
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: