下载
下载地址:https://downloads.mysql.com/archives/community/
cd /home
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-boost-8.0.28.tar.gz
安装依赖
apt-get update
apt-get upgrade
apt install build-essential cmake bison libncurses5-dev libssl-dev pkg-config
解压
cd /home
tar -xvf mysql-boost-8.0.28.tar.gz
安装
cd /home/mysql-8.0.28/
cmake -DCMAKE_INSTALL_PREFIX=/www/server/mysql -DMYSQL_UNIX_ADDR=/www/server/mysql/mysql.sock -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/www/server/mysql/data -DWITH_BOOST=boost -DWITH_SYSTEMD=1
make -j4
make install
设置环境变量
echo "PATH=$PATH:/www/server/mysql/bin" >> /etc/profile
source /etc/profile
配置数据库my.cnf
vim /etc/my.cnf
内容如下:
[client]
port = 3306
socket=/www/server/mysql/mysql.sock
[mysqld]
user = mysql
basedir=/www/server/mysql
datadir=/www/server/mysql/data
port = 3306
character-set-server=utf8
pid-file = /www/server/mysql/mysqld.pid
socket=/www/server/mysql/mysql.sock
bind-address = 0.0.0.0
skip-name-resolve
max_connections=2048
default-storage-engine=INNODB
max_allowed_packet=16M
server-id = 1
创建mysql用户
useradd -U mysql
mkdir -p /www/server/mysql/data
chown -R mysql:mysql /www/server/mysql/
chown mysql:mysql /etc/my.cnf
初始化数据库
cd /www/server/mysql/bin
./mysqld --initialize-insecure --user=mysql --basedir=/www/server/mysql --datadir=/www/server/mysql/data
添加至系统服务
cp /www/server/mysql/lib/systemd/system/mysqld.service /usr/lib/systemd/system/
systemctl daemon-reload
systemctl start mysqld.service
systemctl enable mysqld
#查看是否已启动
netstat -anpt | grep 3306
设置数据库root密码
mysqladmin -u root -p password "123456"
测试登录数据库
mysql -uroot -p123456