DDraceNetwork服务器使用mysql
由于ddnet官网发布的release版本是不带mysql的,所以需要自己编译支持mysql的ddnet-server
使用debian11系统示例,
更新软件包
apt update && apt upgrade
安装依赖
apt install build-essential cargo cmake git glslang-tools google-mock libavcodec-extra libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev libcurl4-openssl-dev libfreetype6-dev libglew-dev libnotify-dev libogg-dev libopus-dev libopusfile-dev libpng-dev libsdl2-dev libsqlite3-dev libssl-dev libvulkan-dev libwavpack-dev libx264-dev python rustc spirv-tools -y
apt install libmariadbclient-dev -y
安装mariadb
apt install mariadb-server
设置root密码
mysql_secure_installation
systemctl start mariadb
编译DDnet-server
git clone --shallow-exclude=included-libs https://ghproxy.com/https://github.com/ddnet/ddnet
mkdir build
cd build
cmake .. -DMYSQL=ON
make -j$(nproc)
创建数据库和用户
create database ddnet;
CREATE USER 'ddnet'@'localhost' IDENTIFIED BY 'thebestpassword';
GRANT ALL PRIVILEGES ON ddnet.* TO 'ddnet'@'localhost';
flush privileges;
允许远程连接
grant all privileges on *.* to ddnet@"%" identified by "thebestpassword" with grant option;
flush privileges;
修改/etc/mysql/mariadb.conf.d/50-server.cnf的bind-address = 127.0.0.1
为bind-address = 0.0.0.0
systemctl restart mariadb
修改服务器配置文件
sv_use_sql 1
add_sqlserver r ddnet record ddnet "thebestpassword" "localhost" "3306"
add_sqlserver w ddnet record ddnet "thebestpassword" "localhost" "3306"第一个ddnet为数据库名,record为表前缀名,第二个ddnet为用户名,thebestpassword为密码,localhost为地址,3306为mysql端口