操作系统: Ubuntu 22.04
操作用户:root
1 安装 MySQL 8 {#1-%E5%AE%89%E8%A3%85-mysql-8}
使用 root 用户安装,切换至 root
sudo -s
1.1 下载 MySQL 8 {#1.1-%E4%B8%8B%E8%BD%BD-mysql-8}
wget https://cdn.mysql.com/archives/mysql-8.1/mysql-8.1.0-linux-glibc2.28-x86_64.tar
1.2 安装依赖 {#1.2-%E5%AE%89%E8%A3%85%E4%BE%9D%E8%B5%96}
apt-get -y install libaio1 libaio-dev libtinfo5
1.3 创建 MySQL 用户指定默认组 {#1.3-%E5%88%9B%E5%BB%BA-mysql-%E7%94%A8%E6%88%B7%E6%8C%87%E5%AE%9A%E9%BB%98%E8%AE%A4%E7%BB%84}
groupadd mysql
`useradd -g mysql mysql -s /usr/sbin/nologin`
1.4 解压、更改文件夹权限 {#1.4-%E8%A7%A3%E5%8E%8B%E3%80%81%E6%9B%B4%E6%94%B9%E6%96%87%E4%BB%B6%E5%A4%B9%E6%9D%83%E9%99%90}
cp mysql-8.1.0-linux-glibc2.28-x86_64.tar /opt
cd /opt
tar -xf mysql-8.1.0-linux-glibc2.28-x86_64.tar
tar -xf mysql-8.1.0-linux-glibc2.28-x86_64.tar.xz
mv mysql-8.1.0-linux-glibc2.28-x86_64/ mysql
mkdir /opt/mysql/data
mkdir /opt/mysql/logs
`chown -R mysql:mysql /opt/mysql`
1.5 创建配置文件 my.cnf {#1.5-%E5%88%9B%E5%BB%BA%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6-my.cnf}
cat >> /etc/my.cnf << EOF
\[mysqld\]
datadir=/opt/mysql/data
basedir=/opt/mysql
pid-file=/opt/mysql/mysql.pid
socket=/tmp/mysql.sock
log-error=/opt/mysql/logs/error.log
default-storage-engine=INNODB
character_set_server=utf8
lower_case_table_names=1
table_open_cache=128
max_connections=2000
max_connect_errors=6000
innodb_file_per_table=1
innodb_buffer_pool_size=1G
max_allowed_packet=64M
transaction_isolation=READ-COMMITTED
innodb_flush_method=O_DIRECT
innodb_lock_wait_timeout=1800
innodb_flush_log_at_trx_commit=0
sync_binlog=0
group_concat_max_len=1024000
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
skip-name-resolve
\[mysql\]
default-character-set=utf8
\[mysql.server\]
default-character-set=utf8
`EOF`
1.6 添加环境变量 {#1.6-%E6%B7%BB%E5%8A%A0%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F}
vim /etc/profile //全局
添加 export PATH=$PATH:/opt/mysql/bin
vim .bashrc // 当前用户
`添加 export PATH=$PATH:/opt/mysql/bin`
1.7 初始化 MySQL {#1.7-%E5%88%9D%E5%A7%8B%E5%8C%96-mysql}
/opt/mysql/bin/mysqld --initialize --user mysql --basedir=/opt/mysql --datadir=/opt/mysql/data
初始化完成后密码保存在 /usr/local/mysql/logs/error.log
===========================================
`注意记录密码`
1.8 准备启动 MySQL {#1.8-%E5%87%86%E5%A4%87%E5%90%AF%E5%8A%A8-mysql}
cp /opt/mysql/support-files/mysql.server /etc/init.d/
sudo /etc/init.d/mysql.server status
sudo /etc/init.d/mysql.server stop
`sudo /etc/init.d/mysql.server start`
1.9 启动 MySQL 并修改初始密码 {#1.9-%E5%90%AF%E5%8A%A8-mysql-%E5%B9%B6%E4%BF%AE%E6%94%B9%E5%88%9D%E5%A7%8B%E5%AF%86%E7%A0%81}
mysql -uroot -p
# 初始密码可在 /opt/mysql/logs/error.log 中
ALTER USER USER() IDENTIFIED BY 'Password123@mysql';
启用 root 远程登陆
============
update mysql.user set Host='%' where User='root';
GRANT ALL PRIVILEGES ON . TO 'root'@'%' WITH GRANT OPTION;
flush privileges;
创建DataEase库
===========
CREATE DATABASE dataease DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
exit
验证密码
====
`mysql -uroot -pPassword123@mysql -h192.168.1.142 `
1.10 设置开机自启 {#1.10-%E8%AE%BE%E7%BD%AE%E5%BC%80%E6%9C%BA%E8%87%AA%E5%90%AF}
update-rc.d mysql.server defaults
2 安装 DataEase v2 {#2-%E5%AE%89%E8%A3%85-dataease-v2}
2.1 下载安装包 {#2.1-%E4%B8%8B%E8%BD%BD%E5%AE%89%E8%A3%85%E5%8C%85}
在 DataEase 官网 dataease.io下载 DataEase v2.x 版本,并上传至服务器 /opt 目录;
2.2 解压安装包 {#2.2-%E8%A7%A3%E5%8E%8B%E5%AE%89%E8%A3%85%E5%8C%85}
tar -zxvf dataease-offline-installer-v2.2.0.tar.gz
`cd dataease-offline-installer-v2.2.0`
2.3 修改配置文件 {#2.3-%E4%BF%AE%E6%94%B9%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6}
vi install.conf
数据库配置
=====
是否使用外部数据库
---------
DE_EXTERNAL_MYSQL=true
数据库地址
-----
DE_MYSQL_HOST=192.168.1.142
数据库端口
-----
DE_MYSQL_PORT=3306
DataEase 数据库库名
--------------
DE_MYSQL_DB=dataease
数据库用户名
------
DE_MYSQL_USER=root
数据库密码
-----
`DE_MYSQL_PASSWORD=Password123@mysql`
修改位置如下图所示:
2.4 安装 {#2.4-%E5%AE%89%E8%A3%85}
bash install.sh
安装信息如下图所示:
2.5 登录验证 {#2.5-%E7%99%BB%E5%BD%95%E9%AA%8C%E8%AF%81}
浏览器访问 http://服务器IP:8100