# 查询MySQL临时生成密码 $ cat /var/log/mysqld.log | grep password 2019-06-28T10:02:12.733076Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: rldW%6_5J3h< # 进入MySQL登录 $ mysql -u root -p # 使用上述的临时密码进行登录 Enter password: rldW%6_5J3h< Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 11 Server version: 5.7.26-29-57-log Percona XtraDB Cluster (GPL), Release rel29, Revision 03540a3, WSREP version 31.37, wsrep_31.37 # 通过命令修改登录密码 mysql> alter user 'root'@'localhost' identified with mysql_native_password by '所要修改的密码需包含大小写字母、数字及特殊符号';
默认密码检查策略要求必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位,否则会提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements。
5.4 远程访问授权
1 2 3 4 5 6 7 8 9
# 创建远程访问用户 mysql> create user 'root'@'%' identified with mysql_native_password by '远程访问密码'; Query OK, 0 rows affected (0.01 sec) # 允许访问权限 mysql> grant all privileges on *.* to 'root'@'%' with grant option; Query OK, 0 rows affected (0.01 sec) # 刷新权限列表 mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
# 停止MySQL服务 $ systemctl stop mysqld # 修改配置文件 配置节点 $ vi /etc/percona-xtradb-cluster.conf.d/wsrep.cnf # 集群中节点的IP地址(本机填最后) wsrep_cluster_address=gcomm://ip地址,IP地址,本机IP地址(用,号隔开) # In order for Galera to work correctly binlog format should be ROW binlog_format=ROW # MyISAM storage engine has only experimental support default_storage_engine=InnoDB # Slave thread to use wsrep_slave_threads= 8 wsrep_log_conflicts # This changes how InnoDB autoincrement locks are managed and is a requirement for Galera innodb_autoinc_lock_mode=2 # Node IP address # 当前节点IP wsrep_node_address=IP地址 # Cluster name # 集群名称 wsrep_cluster_name=pxc-cluster #If wsrep_node_name is not specified, then system hostname will be used # 当前节点名称 wsrep_node_name=pxc-cluster-node-1 #pxc_strict_mode allowed values: DISABLED,PERMISSIVE,ENFORCING,MASTER # 不使用实验功能 pxc_strict_mode=ENFORCING # SST method #状态快照传输(sst)方法,官方建议 wsrep_sst_method=xtrabackup-v2 #Authentication for SST method # 用户凭证——用于同步(mysql的用户名和密码) wsrep_sst_auth="用户名:密码"
6. PXC初始化主节点
1 2 3 4 5 6 7 8 9 10 11 12
# 其中一个节点使用以下命令启动 $ systemctl start mysql@bootstrap.service # 登入MySQL $ mysql -u root -p # 开启wsrep_causal_reads mysql> set wsrep_causal_reads =1; # 创建配置文件中对应的用户(此步骤所有节点的IP都需要创建) mysql> create user '对应配置文件的用户名'@'%' identified with mysql_native_password by '对应配置文件的密码'; # 给予权限 mysql> grant all privileges on *.* to '用户名'@'%' with grant option; # 刷新权限表 mysql> flush privileges;