mysql:
#安装
apt install mariadb
#打开一个新窗口运行mysql服务
mysqld &
#切换回当前窗口,初始化数据库,设置密码
mariadb-secure-installation
#登录测试
mysql -uroot -p你的密码pgsql:
#安装
apt install postgresql
#创建指定的数据库目录
mkdir $PREFIX/var/lib/postgresql
#初始化数据库
initdb $PREFIX/var/lib/postgresql
#启动数据库服务
pg_ctl -D $PREFIX/var/lib/postgresql -l logfile start
#启动客户端测试
psql -d postgres执行 : yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm -y 2:安装postgres
yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm -yyum list | grep postgresql如果能找到,再执行安装
yum install postgresql12-contrib postgresql12-server -y/usr/pgsql-12/bin/postgresql-12-setup initdbsudo systemctl start postgresql-12
sudo systemctl enable postgresql-12.servicealter user postgres with password '123456';# 1.pg_hba.conf
vim /var/lib/pgsql/12/data/pg_hba.conf
# 文件末尾加入
host all all ::1/128 md5
# 2.postgresql.conf
# listen_addresses = 'localhost'
# 修改为listen_addresses = '*'来创建数据库
CREATE DATABASE testdb;创建用户
CREATE USER testuser CREATEDB LOGIN PASSWORD 'testpassword';
将testdb所有权限赋给用户testuser
GRANT ALL ON DATABASE testdb TO testuser;删除数据库
drop database testdb;删除用户
drop role testuser;