在最近学习databus的过程中,除了看源码,还有很重要的就是实操,databus搭建时候,需要先搭建数据库,mysql的安装和备份还是很久之前做的,好多东西都忘了,索性这次都记录下来
下载安装包
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
安装到/usr/local/mysql下
tar -xvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.22-linux-glibc2.12-x86_64 /usr/local/
新建mysql用户、mysql用户组、赋权
groupadd mysql
useradd mysql -g mysql
chown -R mysql.mysql /usr/local/mysql
配置
/usr/local/mysql/bin/mysql_install_db –user=mysql –basedir=/usr/local/mysql/ –datadir=/usr/local/mysql/data
/usr/local/mysql/bin/mysqld –user=mysql –basedir=/usr/local/mysql/ –datadir=/usr/local/mysql/data –initialize
修改my.cnf
user=mysql
port=3306
character-set-server=utf8
symbolic-links=0
binlog-format=Row 修改binlog格式
server-id=1 指定服务ID
log_bin=/app/mysql/datalog/mysql-bin 指定binlog文件前缀格式
binlog_checksum=NONE 关闭mysql5.6之后binlog解析crc32校验,不然可能导致存库解析binlog失败, 报错示例: Slave can not handle replication events with the checksum that maste
skip-grant-tables 取消密码验证
开机服务
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
chkconfig mysql on
service mysql start
密码
1 | /usr/local/mysql/bin/mysql -u root -p |
删除my.cnf中的skip-grant-tables并修改密码
/usr/local/mysql/bin/mysql -u root -p
>>ALTER USER 'root'@'localhost' IDENTIFIED BY '修改后的密码';
>>exit;
远程连接
/usr/local/mysql/bin/mysql -u root -p
>>use mysql;
>>update user set host='%' where user = 'root';
>>flush privileges;
安装过程中报错,直接查看mysql日志,很多是errcode13,代表权限问题,mysql用户是否对数据库目录内的所有文件具有写的权限