mysql安装步骤

  1. 下载mysql5.6.23

  2. 检测服务是否有mysql
    rpm -qa |grep mysql
    显示mysql-libs-5.1.73-5.el6_6.x86_64

  3. 删除低版本mysql
    yum remove mysql-libs

  4. 解压 tar -zxvf mysql-5.6.23.tar.gz
    cd mysql-5.6.23

  5. 安装依赖包
    sudo yum install cmake gcc-c++ ncurses-devel perl-Data-Dumper

  6. 编译
    cmake .
    make

  7. 安装,会在/use/local/下生成mysql
    sudo make install

  8. 添加mysql用户和组
    cd /usr/local/mysql
    sudo chown -R mysql .
    sudo chgrp -R mysql .
    sudo scripts/mysql_install_db --user=mysql
    sudo chown -R root .
    sudo chown -R mysql data

  9. 创建数据库目录
    mkdir /data/mysql
    chown mysql:mysql /data/mysql

  10. 删除默认配置文件
    cd /etc
    sudo rm -fr my.cnf my.cnf.d

  11. 新建配置文件,配置文件见my.cnf文件

  12. 初始化mysql
    sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &

  13. 初始化数据库,会在/data/mysql/目录下创建mysql数据库,需要在mysql安装目录
    /usr/local/mysql/scripts/mysql_install_db --user=mysql

  14. 配置环境变量
    mysql environment
    export PATH=/usr/local/mysql/bin:$PATH
    alias mysql_start="mysqld_safe&"
    alias mysql_stop="mysqladmin -uroot -p shutdown"

  15. 添加开机启动
    cp /usr/local/mysql/support-files/mysql.server /etc/init.d/
    chkconfig --add mysql

  16. 启动数据库
    /etc/init.d/mysql start

  17. 修改密码
    mysql
    use mysql;
    UPDATE user SET password = PASSWORD('yicha.123') WHERE user = 'root';
    FLUSH PRIVILEGES;

    /etc/inin.d/mysql restart

  18. 主从配置

主:log-bin=mysql-bin
server-id=1
binlog_format=mixed

重启服务

从:log-bin=mysql-bin
binlog_format=mixed
server-id=2
relay-log-index = slave-relay-bin.index
relay-log = slave-relay-bin
sync_master_info = 1
sync_relay_log = 1
sync_relay_log_info = 1

重启服务,登录
change master to master_host='10.10.63.106',master_user='mysqlrsync',master_password='mysql';
start slave;
show slave status\G;

my.inf文件

# 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.

[mysqld]

# 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 = .....

# 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 
user=mysql
datadir=/data/mysql
default-storage-engine=MyISAM

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容