目 录CONTENT

文章目录

termux安装和配置postgresql和mysql

qaiu
2020-04-22 / 2 评论 / 0 点赞 / 4,597 阅读 / 0 字 / 正在检测是否收录...
温馨提示:
欢迎加入C4droid交流群: 1026766509(验证问题自行百度)
有什么疑问可以评论区留言,也可以加QQ736226400咨询
也可以进入问题反馈平台上传相关错误信息或者截图
提问之前建议阅读下提问的智慧
小站运营不易,还请不要屏蔽广告😘
本站内容长期更新,点击这里去打赏支持
手机支付宝用户点击这里打赏博主喝杯咖啡吧❤️❤️

mysql已经贱卖了,mariadb才是亲闺女

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

centos7安装pgsql12

执行 : yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm -y
2:安装postgres

  1. 更新源
yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm -y
  1. 安装
    先查看postgresql源
yum list | grep postgresql

如果能找到,再执行安装

yum install postgresql12-contrib postgresql12-server -y
  1. 初始化数据库
/usr/pgsql-12/bin/postgresql-12-setup initdb
  1. 设置开机启动
sudo systemctl start postgresql-12
sudo systemctl enable postgresql-12.service
  1. 登录postgresql并设置密码
    postgresql在安装时默认添加用户postgres
    设置密码
alter user postgres with password '123456';
  1. 设置外网访问,修改两个配置文件
# 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 = '*'来

  1. 重启pgsql
    systemctl restart postgresql-12

pgsql用户基本

创建数据库

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;
0

评论区