Bootstrap

centos安装mysql主从_centos7安装MySQL及配置实现主从同步

1.下载安装:

wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm

yum localinstall mysql57-community-release-el7-8.noarch.rpm

(提示进程占用,直接kill就行)

检查mysql源是否安装成功

yum repolist enabled | grep "mysql.*-community.*"

进行安装

yum install mysql-community-server

安装完成后启动一下 看看有什么问题没;

systemctl start mysqld

没啥问题修改密码:

sudo grep 'temporary password' /var/log/mysqld.log

通过上述命令找到你的密码

mysql -uroot -p

输入密码进入修改你的root账号密码

修改完密码退出MySQL,出来修改目录了。

2.修改目录:

由于MySQL的数据存的比较大,需要换个路径储存数据,你不可能把你的所有的数据都放在数据库安装的目录下把,所以我们在data目录下创建一个datamysql目录来专门放MySQL的数据。

*以下操作需要root权限:

mkdir datamysql

mkdir datamysql/mysql

cp -R /var/lib/mysql/* /data/datamysql/mysql/

chown -R mysql:mysql /data/datamysql/mysql/

cp /etc/my.cnf /etc/my.cnf.bak

修改配置文件:

# For advice on how to change settings please see

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

[client]

port=3306

socket=/data/datamysql/mysql/mysql.sock

default-character-set=utf8

[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_s

;