常用数据源数据库安装配置
RPM 包查询位置 http://www.rpmfind.net/
MySQL 8
Download: https://dev.mysql.com/downloads/repo/yum/ ### 安装 安装前,我们可以检测系统是否自带安装 MySQL:
rpm -qa | grep mysql
如果你系统有安装,那可以选择进行卸载:
rpm -e mysql // 普通删除模式rpm -e --nodeps mysql // 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除
下载RPM包后
wget <https://dev.mysql.com/get/mysql80-community-release-el7-9.noarch.rpmrpm> -ivh mysql80-community-release-el7-9.noarch.rpmyum updateyum install mysql-server
权限设置:
chown -R mysql:mysql /var/lib/mysql/
初始化 MySQL:
mysqld --initialize
启动 MySQL:
#启动服务systemctl start mysqld#设置为开机启动systemctl enable mysqld
查看 MySQL 运行状态:
systemctl status mysqld
配置
Mysql安装成功后,默认的root用户密码为空,你可以使用以下命令来创建root用户的密码:
mysqladmin -u root password "new_password";
现在你可以通过以下命令来连接到Mysql服务器:
mysql -u root -p
Oracle Database
Download:
Version: oracle-database-ee-19c-1.0-1.x86_64
安装
yum install oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpmyum install oracle-database-ee-19c-1.0-1.x86_64.rpm# 配置数据库/etc/init.d/oracledb_ORCLCDB-19c configure# 配置环境变量su - oraclevi .bash_profileexport ORACLE_HOME=/opt/oracle/product/19c/dbhome_1export PATH=$PATH:/opt/oracle/product/19c/dbhome_1/binexport ORACLE_SID=ORCLCDBsource .bash_profile
启动和关闭
登录到CentOS,切换到oracle用户权限
su - oracle
接着输入:
$ sqlplus "/as sysdba"
接着请输入
SQL> startup
另外停止数据库的指令如下:SQL> shutdown normalor
SQL> shutdown immediate
连接
# 切换用户
su - oracle
# 连接数据库
sqlplus / as sysdba
# 执行
select global_name from global_name;
# 记住GLOBAL_NAME,这是服务名连接时会用到
# 创建用户并加权限
create user c##cashway identified by cashway;
grant dba to cashway;
PostgreSQL
Version: 15.4 Linux x86_64
Use Yum Repository
# Install the repository RPM:sudo yum install -y <https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm#> Install PostgreSQL:sudo yum install -y postgresql15-server# Optionally initialize the database and enable automatic start:sudo /usr/pgsql-15/bin/postgresql-15-setup initdbsudo systemctl enable postgresql-15sudo systemctl start postgresql-15
Direct RPM install
可能需要的依赖:
rpm -ivh [package name]
下载源码包wget <https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz解包,解压缩xz> -d Python-3.6.1.tar.xztar -xvf Python-3.6.1.tar 编译cd Python-3.6.1./configure --prefix=/usr/local/python3.6 --enable-optimizationsmakemake install
# 提示 zlib not available yum install zlib-devel # 解决 import bz2 报错 yum install bzip2-devel # 解决 import curses 报错 yum install ncurses-devel # 解决 import sqlite3 报错 yum install sqlite-devel # 解决 _dbm _gdbm 缺失提醒 yum install gdbm-devel # 解决 _lzma 缺失提醒 yum install xz-devel # 解决 _tkinter 缺失提醒 yum install tk-devel # 解决 readline 缺失提醒及方向键行为非预期的问题 输出变成了^[[D^[[A 类似这样的内容 yum install readline-devel
下载:PostgreSQL Database Server 15 PGDG
postgresql15 - PostgreSQL client programs and libraries
postgresql15-contrib - Contributed source and binaries distributed with PostgreSQL
postgresql15-libs - The shared libraries required for any PostgreSQL clients
postgresql15-server - The programs needed to create and run a PostgreSQL server
安装:
执行以下命令顺序 libs>12.10>server>contrib
rpm -ivh postgresql15-libs.rhel7.x86_64.rpmrpm -ivh postgresql15-15.rhel7.x86_64.rpmrpm -ivh postgresql15-server.rhel7.x86_64.rpmrpm -ivh postgresql15-contrib.rhel7.x86_64.rpm
初始化数据库
/usr/pgsql-15/bin/postgresql-15-setup initdb
启动服务
systemctl start postgresql-15
配置
允许其他ip访问和端口号设置
vim /var/lib/pgsql/15/data/postgresql.conflisten_addresses = '*' 表示监听所有的ip信息port = 5432 表示服务的端口,可以自定义为其他端口# 修改 postgreSQL 配置vim /var/lib/pgsql/15/data/pg_hba.conf# 文件最下面修改/添加# TYPE DATABASE USER ADDRESS METHODhost all all 0.0.0.0/0 md5# 重启服务systemctl restart postgresql-15
创建用户及数据库
切换到postgres用户
su - postgrespsql -p 5432
创建数据库用户名
create user cashway with password 'cashway@2022';
创建数据库
create database testdb;
将testdb授权给test用户