环境简介
Linux :CentOS 6.9
mysql版本:MySQL5.6.30
———————————————————————————————————————————————————————
MySQL5.6.30安装
前期准备
创建mysql用户与mysql组
创建组: groupadd mysql
创建用户: useradd -r -g mysql mysql
在mysql文件夹内创建用于数据存放的文件夹data
mkdir -p /usr/local/mysql/data
在mysql解压文件夹内执行make && make install
进行相应的配置
1、将 support-files 里面的 my-default.cnf 移到 conf 里面,改名为 my.cnf
cp support-files/my-default.cnf conf/my.cnf
2、修改my.cnf配置文件,如下:
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/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'
# 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 = /usr/local/mysql/data/mysqldb
# port = .....
# server_id = .....
socket = /usr/local/mysql/mysql.sock
pid-file = /usr/local/mysql/data/mysqldb/mysql.pid
# 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
3.创建用于数据库存放文件夹 mysql/data/mysqldb
mkdir -p /usr/local/mysql/data/mysqldb
4.分配权限
chown -R mysql:mysql /usr/local/mysql
初始化mysql
./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysqldb
复制mysql启动服务脚本 至 /etc/init.d目录下
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
启动与关闭mysql
启动:support-files/mysql.server start
关闭:support-files/mysql.server stop
测试连接mysql
bin/mysql
bin/mysql -uroot
show databases;
启动mysql
service mysqld start
关闭mysql
service mysqld stop
查看运行状态
service mysqld status