本文讲解liunx环境安装MySQL集群的第一步安装MySQL服务,如下: 本来想安装一主一备两从的,本人目前机器不足哦,只准备了三台机器。望见谅。
IP | 系统 | MySQL版本 | 节点 |
---|
172.16.186.161 | Centos7.6 | 8.0 | 主 | 172.16.186.162 | Centos7.6 | 8.0 | 备 | 172.16.186.163 | Centos7.6 | 8.0 | 从 |
我这里默认三台机器都没安装MySQL 。 如果你们有安装MySQL 的话,可以先卸载,这里就不讲解卸载的方式了,可自行百度。
首先去官方网站下载最新版本: MySQL官方地址
我们选择liunx 通用,进行下载就好了。 下载好了,将包上传到你的服务器上。
我这里就通过 scp 工具上传
$ scp mysql-cluster-8.0.28-linux-glibc2.12-x86_64.tar.gz root@172.16.185.163:/usr/local/src
下面我们开始安装: 这里我只演示一台服务器的安装,其它两台时一样的操作。
[root@主 src]
[root@主 src]
mysql-cluster-8.0.28-linux-glibc2.12-x86_64
mysql-cluster-8.0.28-linux-glibc2.12-x86_64.tar.gz
[root@主 src]
[root@主 mysql]
/usr/local/mysql
[root@主 mysql]
bin docs include lib LICENSE man README share support-files
[root@主 mysql]
[root@主 mysql]
[root@主 mysql]
[root@主 mysql]
[root@主 mysql]
[root@主 bin]
2022-03-05T07:49:30.424376Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2022-03-05T07:49:30.424858Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.28-cluster) initializing of server in progress as process 7565
2022-03-05T07:49:30.443261Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-03-05T07:49:30.984264Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-03-05T07:49:32.837028Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: w8JEll;yTU:X
[root@主 bin]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
!includedir /etc/my.cnf.d
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/
socket=/tmp/mysql.sock
character-set-server=UTF8MB4
[root@主 bin]
[mysqld]
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/
socket=/tmp/mysql.sock
character-set-server=UTF8MB4
symbolic-links=0
!includedir /etc/my.cnf.d
[root@主 mysql]
[root@主 mysql]
[root@主 mysql]
[root@主 mysql]
Starting MySQL.Logging to '/usr/local/mysql/data/主.err'.
SUCCESS!
[root@主 mysql]
SUCCESS! MySQL running (7960)
[root@主 mysql]
[root@主 mysql]
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.28-cluster
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
使用Navicat 远程登陆
可能会报错:Can’t connect to MySQL server
这个可能是你的防火墙的问题,你关闭一下就行了:
关闭防火墙
firewall-cmd --state
systemctl stop firewalld.service
systemctl disable firewalld.service
至此三台机器安装MySQL 已完成。
|