[root@node1 local]# mv /root/mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz /usr/local/
[root@hadoop1 local]# tar -zxvf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
[root@hadoop1 local]# mv mysql-5.7.28-linux-glibc2.12-x86_64 mysql
[root@hadoop1 local]# cd mysql
[root@hadoop1 mysql]# mkdir arch tmp relay_log
[root@hadoop1 local]# groupadd -g 101 dba
[root@hadoop1 mysql]# cat /etc/group | tail -n 3
postfix:x:89:
ntp:x:38:
dba:x:101:
/usr/local/mysql/
[root@hadoop1 local]# useradd -g dba -d /usr/local/mysql/ mysql
[root@hadoop1 local]# cp /etc/skel/.bash_profile /usr/local/mysql/
[root@hadoop1 local]# cp /etc/skel/.bash_logout /usr/local/mysql/
[root@hadoop1 local]# cp /etc/skel/.bashrc /usr/local/mysql/
[mysql@hadoop1 ~]$ vi /usr/local/mysql/.bash_profile
#mysql
export MYSQL=/usr/local/mysql
export PATH=$PATH:$MYSQL/bin
上传my.cnf
[root@hadoop1 ~]# mv my.cnf /etc/
[root@hadoop1 ~]# chown mysql:dba /etc/my.cnf
[root@hadoop1 ~]# chmod 640 /etc/my.cnf
[root@hadoop1 ~]# chown -R mysql:dba /usr/local/mysql/
[root@hadoop1 ~]# chmod -R 755 /usr/local/mysql/
[root@hadoop1 ~]# cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysql
[root@hadoop1 ~]# chmod +x /etc/rc.d/init.d/mysql
[root@hadoop1 ~]# chkconfig --add mysql
[root@hadoop1 ~]# chkconfig mysql on
[root@hadoop1 ~]# yum -y install libaio
[root@hadoop1 ~]# su - mysql
# data是mysql数据库存放数据的目录
[mysql@hadoop1 ~]$ mkdir data
#初始化mysql
[mysql@hadoop1 mysql]$ bin/mysqld --defaults-file=/etc/my.cnf --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
[mysql@hadoop1 data]$ cat /usr/local/mysql/data/hostname.err | grep password
[mysql@hadoop1 data]$ /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf &
[mysql@hadoop1 data]$ service mysql status
#也可以去看一下mysql的进程在不在
[mysql@hadoop1 data]$ ps -elf | grep mysql (会发现mysql进程正在启动)
需要进入mysql
mysql -uroot -p
mysql> alter user root@localhost identified by 123456;
mysql> grant all privileges on *.* to root@% identified by 123456;
mysql> flush privileges;
[mysql@hadoop1 mysql]$ ps -elf | grep mysql
[mysql@hadoop1 mysql]$ kill -9 [PID]
检查你的密码对不对;
检查你的mysql有没有启动,需要重新启动,而且需要再添加开机自动启动。
[mysql@hadoop1 ~]$ service mysql status
SUCCESS! MySQL running (7661)
如果是success没有问题。
[mysql@hadoop1 ~]$ ps -elf | grep mysql
看一下有没有这个进程。
mysqldump -uroot -p123456 test user > user.sql
[mysql@hadoop1 mysql]$ mysql -uroot -p123456 -s -e "show databases;" | grep -v Database
mysql: [Warning] Using a password on the command line interface can be insecure.
information_schema
mysql
performance_schema
sys
test
test2
[mysql@hadoop1 mysql]$ mysql -uroot -p123456 -s -e "use test;show tables;" | grep -v Tables_in
mysql: [Warning] Using a password on the command line interface can be insecure.
user
开启binlog日志需要在配置文件中添加:
查看binlog日志文件的命令:
[mysql@hadoop1 arch]$ mysqlbinlog --no-defaults --base64-output=decode-rows -vvv mysql-bin.000003
[mysql@hadoop2 relay_log]$ exit
logout
[root@hadoop2 ~]# service mysql restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
创建用户:
mysql> create user reproduce@localhost identified by 123456;
Query OK, 0 rows affected (0.02 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
验证:
远程访问:
加权限(在主库使用root用户):
mysql> grant replication slave on *.* to reproduce@% identified by 123456;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
验证:
change master to
master_host=192.168.174.10,
master_port=3306,
master_user=reproduce,
master_password=123456,
master_log_file=mysql-bin.000002,
master_log_pos=1680;
IO_thread
SQL_thread
mysql> start slave;
Query OK, 0 rows affected (0.02 sec)
mysql> show slave statusG
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
[mysql@hadoop2 relay_log]$ mysqlbinlog --no-defaults --base64-output=decode-rows -vvv relay-log.000002
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/129632.html
摘要:环境主机从机环境目标实现主机到从机基于的主从复制目前提供两种方式主从复制基于我们此篇就是基于的主从复制基于第步下载并分别安装到主机和从机,网上有很多例子。第步在主机和从机上分别拷贝配置文件到下。可以创建库或者表查看同步情况。 环境 主机:172.17.0.2从机:172.17.0.3环境:CentOS7MySQL:5.6.38目标:实现主机172.17.0.2到从机172.17.0.3...
摘要:环境主机从机环境目标实现主机到从机基于的主从复制目前提供两种方式主从复制基于我们此篇就是基于的主从复制基于第步下载并分别安装到主机和从机,网上有很多例子。第步在主机和从机上分别拷贝配置文件到下。可以创建库或者表查看同步情况。 环境 主机:172.17.0.2从机:172.17.0.3环境:CentOS7MySQL:5.6.38目标:实现主机172.17.0.2到从机172.17.0.3...
阅读 1347·2023-01-11 13:20
阅读 1687·2023-01-11 13:20
阅读 1135·2023-01-11 13:20
阅读 1861·2023-01-11 13:20
阅读 4104·2023-01-11 13:20
阅读 2708·2023-01-11 13:20
阅读 1386·2023-01-11 13:20
阅读 3599·2023-01-11 13:20