ubuntu20.4安装 mariadb 最新版

通过官网查看
https://mariadb.org/

文档

https://downloads.mariadb.org/mariadb/repositories/
ubuntu20.4安装 mariadb 最新版_第1张图片
最新版为 10.5.x
fox.风

设置数据源-清华大学

sudo apt-get install software-properties-common
sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] https://mirrors.tuna.tsinghua.edu.cn/mariadb/repo/10.5/ubuntu focal main'

安装 mariadb

sudo apt update
sudo apt -y install mariadb-server
# 安装完成 默认自启动
# 如果没有 请用如下 查看
sudo systemctl status mariadb
# 开机自启动
sudo systemctl enable mariadb  --now

设置密码

sudo mysql_secure_installation

设置管理用户

命令输入 mysql

# 设置权限
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' IDENTIFIED BY 'very_strong_password';
或
GRANT ALL PRIVILEGES on *.* TO 'admin'@'%' IDENTIFIED BY 'admin' with grant option;

# 设置 密码
SET PASSWORD FOR admin=PASSWORD('admin');
# 应用刷新
flush privileges;
# 退出
exit;

设置远程可以登录

如果不设置,只能本机内访问

sudo vim /etc/mysql/mariadb.conf.d/50-server.cnf

bind-address=XXX 修改为 如下,表允许所有地址

bind-address=0.0.0.0

最后重启

sudo systemctl restart mariadb

其他命令

# 重启
sudo systemctl restart mariadb
# 启动
sudo systemctl start mariadb
# 关闭
sudo systemctl stop mariadb
# 状态
sudo systemctl status mariadb

修改端口

如果需要修改端口号的同学可以按如下修改,如不需要修改,直接 PASS

sudo vim /etc/mysql/my.cnf

#port                   = 3306

修改为你想要设置的端口

port                   = 3306

你可能感兴趣的:(数据库,sql,系统,服务器,平台)