Ubuntu数据库下载:安装教程 (ubuntu数据库下载)

Ubuntu是一种广泛使用的Linux操作系统。由于其开放源代码、稳定、安全等特点,已经成为了许多数据库管理系统的首选操作系统。而在Ubuntu上安装数据库也非常简单,本文将会为您介绍Ubuntu数据库的下载及安装教程。

一、下载数据库

1.1 在线下载

在Ubuntu的官方站点上,你可以找到多个类型和版本的数据库。如果你想在线下载,那么打开终端窗口,执行以下命令:

$ sudo apt-get install mysql-server

这将下载并安装最新版本的MySQL数据库。

1.2 离线下载

如果你的服务器没有网络连接,那么可以选择离线下载方式。建议使用官方站点上的Cubrid和MariaDB(相对于不受信任的外部下载源)。

在你的桌面上创建一个新的目录,再到数据库的官方网站上下载你需要的版本。将它们保存到你刚刚创建的目录中。

二、安装数据库

2.1 安装MySQL

安装MySQL非常简单,只需运行以下命令即可:

$ sudo apt-get install mysql-server

在安装过程中,系统会要求你设置MySQL管理员的密码。请记住这个密码,它会在你安装任何MySQL客户端并连接到数据库时用到。

2.2 安装PostgreSQL

和MySQL安装 PostgreSGL也是非常简单的。我们先使用以下命令更新apt-get的软件仓库:

$ sudo apt-get update

然后运行以下命令安装PostgreSQL:

$ sudo apt-get install postgresql postgresql-contrib

在安装过程中,系统会提示你输入PostgreSQL管理员的密码。请记住这个密码,之后会用到。

2.3 安装MongoDB

安装MongoDB也是很简单的。运行以下命令来安装:

$ sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv 7F0CEB10

$ echo “deb http://repo.mongodb.org/apt/ubuntu “$(l_release -sc)”/mongodb-org/3.0 multiverse” | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list

$ sudo apt-get update

$ sudo apt-get install -y mongodb-org

安装完成后,你只需要运行以下命令即可启动MongoDB:

$ sudo service mongod start

三、配置数据库

安装完成后,你需要配置数据库以便能够正常使用。一般来说,如果你使用的是Linux的基本安装,那么你的数据库应该已经有了基本的配置。

如果你想进一步配置数据库,请按照以下步骤:

3.1 配置MySQL

MySQL的默认配置非常安全。但是如果你想进一步保护它,你可以做出以下几个配置:

从远程访问MySQL

默认情况下,只有本地用户能够访问MySQL。如果你想从远程访问MySQL,可以修改以下文件:

$ nano /etc/mysql/mysql.conf.d/mysqld.cnf

然后在[mysqld]段中添加以下行:

bind-address = 0.0.0.0

回到终端,重启MySQL:

$ sudo service mysql restart

3.2 配置PostgreSQL

PostgreSQL的默认配置也是非常安全的,但是如果你想进一步保护它,你可以做出以下几个配置:

修改PostgreSQL监听的端口

PostgreSQL默认监听5432端口。你可以在以下文件中修改这个端口:

$ sudo nano /etc/postgresql/13/mn/postgresql.conf

在该文件中找到以下行:

#listen_addresses = ‘localhost’

并将它修改为:

listen_addresses = ‘*’

这将使PostgreSQL监听所有网络接口。完成后,请保存并退出该文件。

通过以下命令重启PostgreSQL:

$ sudo service postgresql restart

3.3 配置MongoDB

MongoDB默认情况下使用27017端口。你可以在/etc/mongod.conf文件中进行端口的修改:

$ sudo nano /etc/mongod.conf

找到:

# network interfaces

net:

port: 27017

bindIp: 127.0.0.1

并将bindIp修改为0.0.0.0。

重启MongoDB使配置生效:

$ sudo systemctl restart mongod

四、连接数据库

安装和配置完数据库后,你就可以开始连接数据库了。以下是连接MySQL、PostgreSQL和MongoDB的方法:

4.1 连接MySQL

使用以下命令连接MySQL:

$ mysql -u root -p

然后输入之前设置的MySQL管理员密码。之后就可以开始使用MySQL了。

4.2 连接PostgreSQL

使用以下命令连接PostgreSQL:

$ sudo -u postgres psql

输入之前设置的PostgreSQL管理员密码。之后就可以开始使用PostgreSQL了。

4.3 连接MongoDB

使用以下命令连接MongoDB:

$ mongo

接下来你就可以通过MongoDB Shell进入交互式操作界面来对数据库进行配置或操作。

至此,你已经成功地在Ubuntu上安装了MySQL、PostgreSQL和MongoDB数据 库,并完成了一些简单的配置和连接操作。根据实际需要,你还可以订制更多的功能和选项。不过,希望我们介绍的内容能够帮助你成功地安装、配置、连接数据库。

相关问题拓展阅读:

求一个能安装在Linux系统Ubuntu 上面的Oracle 10g 64 位 数据库,跪求

之一步,安装必须的包:

32位安装:

apt-get install gcc make binutils lesstif2 libc6 libc6-dev rpm libmotif3 libaio1 libstdc++6 alien

64位安装:

sudo apt-get install gcc libaio1 lesstif2 lesstif2-dev make libc6 libc6-i386 libc6-dev-i386 libstdc++5 lib32stdc++6 lib32z1 ia32-libs

第二步携卜,添加用户:

# adduser oracle

正辩槐穗在添加用户”oracle”…

正在添加新组”oracle” (1001)…

正在添加新用户”oracle” (1002) 到组”oracle”…

创建主目录”/home/oracle”…

正在从”/etc/skel”复制文件…

输入新的 UNIX 密码:

重新输入新的 UNIX 密码:

passwd:已成功更新密码

Changing the user information for oracle

Enter the new value, or press ENTER for the default

Full Name : oracle

Room Number :

Work Phone :

Home Phone :

Other :

第三步,修改设置

A.设置swap区

Oracle10g至少需要500M的内存和400M的交明空换空间,要查看swap区是否足够大小,用 fdisk -l 命令去查,如果小于400M的空间,那么就要增加swap的大小 重设交换分区可以使用如下操作:

dd if=/dev/zero of=tmp_swap bs=1k count=900000

chmod 600 tmp_swap

mkswap tmp_swap

swapon tmp_swap

完成安装以後,可以释放这个空间:

swapoff tmp_swap

rm tmp_swap

count 值是根据你需要调整的交换分区大小而定。

B.修改 sysctl.conf

添加如下的行到/etc/sysctl.conf 中:

kernel.shmmax =

kernel.shmmni = 4096

kernel.shmall =

kernel.sem = 128

fs.file-max = 65536

net.ipv4.ip_local_port_range =

C.修改 limits.conf

添加如下的行到/etc/security/limits.conf中:

* soft nproc 2407

* hard nproc 16384

* soft nofile 1024

* hard nofile 65536

D.让修改生效

修改了以上文件後,必须让其生效,或重启系统,或切换到 root 用户下用以下的方式改变内核运行参数: sysctl -p

E.产生相应的软连接

创建一个文件如 kk,内容如下:

#!/bin/bash

ln -s /usr/bin/awk /bin/awk

ln -s /usr/bin/rpm /bin/rpm

ln -s /usr/bin/basename /bin/basename

mkdir /etc/rc.d

ln -s /etc/rc0.d /etc/rc.d/rc0.d

ln -s /etc/rc2.d /etc/rc.d/rc2.d

ln -s /etc/rc3.d /etc/rc.d/rc3.d

ln -s /etc/rc4.d /etc/rc.d/rc4.d

ln -s /etc/rc5.d /etc/rc.d/rc5.d

ln -s /etc/rc6.d /etc/rc.d/rc6.d

ln -s /etc/init.d /etc/rc.d/init.d

创建後,切换到 root 用户去执行一下。

F.创建RedHat的版本声明文件

在/etc/redhat-release中添加以下语句,以使安装程序认为正在一个RedHat的系统上安装:

Red Hat Linux release 3.1 (drupal)

G.修改环境变量

编辑 /home/oracle/.bashrc,增加以下export 的内容。 (注意,在Ubnutu 7.04中用户的profile文件已改名为~/.profile,有很多安装教程都是用 ~/.bash_profile,在7.04中不行的)

export ORACLE_HOME=/opt/ora10

export ORACLE_OWNER=oracle

export ORACLE_SID=ora1

export ORACLE_TERM=xterm

export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin:$PATH

第四步,开始安装

注销原来的用户,改用oracle用户登录。用env查看一下环境变量是否生效。 然後进行/ora_ins_disk中进行安装,执行安装脚本时还需要以root权限创建目录/opt/ora10

sudo mkdir /opt/ora10

sudo chown -R oracle:oracle /opt/ora10

sudo chmod -R 770 /opt/ora10

cd/ora_ins_disk

./runInstaller

在安装过程中,请使用 Advanced Installation,然後一路按默认的设置进行往下设置,到窗单名为 “Specify Database Configuration Options”的时候,要修改以下设置: Database Character Set 中选择 Simplified Chinese ZHS16GBK 在安装的後期,系统提示需要用 root 用户去运行两个脚本文件orainstRoot.sh和root.sh,安装完毕後,Oracle是正常启动着的,你可以试一下连接数据库,同时也可以使用浏览器去设置一下Oracle,(url:http: //localhost:1158/em/)(Oracle 10g与之前的版本都不一样,使用WEB页的企业管理器来代替以前的C/S版JAVA企业管理器)

第六步,设置自启动

创建自启动脚本 创建 oracledb 脚本到/etc/init.d/oracledb,内容如下

#!/bin/bash

#

# /etc/init.d/oracledb

#

# Run-level Startup script for the Oracle Instance, Listener, and

# Web Interface

export ORACLE_HOME=/opt/ora10

export ORACLE_SID=ora1

export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin:$PATH

ORA_OWNR=”oracle”

# if the executables do not exist — display error

if

then

echo ” dbstart command does not exist, quitting…”

exit 1

else

echo ” dbstart existance check OK”

fi

# depending on parameter — startup, shutdown, restart

# of the instance and listener or usage display

case “$1” in

start)

# Oracle listener and instance startup

echo ” Starting oracle”

echo ” su $ORA_OWNR -c “”$ORACLE_HOME/bin/lsnrctl start”

su $ORA_OWNR -c “$ORACLE_HOME/bin/lsnrctl start”

if

then

echo ” listener failed to start”

exit 1

else

echo ” listener start OK”

fi

su $ORA_OWNR -c “$ORACLE_HOME/bin/dbstart $ORACLE_HOME”

echo ” su $ORA_OWNR -c “”$ORACLE_HOME/bin/dbstart $ORACLE_HOME”

if

then

echo ” dbstart failed to start”

exit 1

else

echo ” dbstart OK”

fi

touch /var/lock/oracle

echo “su $ORA_OWNR -c “”$ORACLE_HOME/bin/emctl start dbconsole”

su $ORA_OWNR -c “$ORACLE_HOME/bin/emctl start dbconsole”

if

then

echo ” dbconsole failed to start”

exit 1

else

echo ” dbconsole start OK”

fi

echo ” Starting oracle ended OK”

;;

stop)

# Oracle listener and instance shutdown

echo ” Shutdown Oracle: “

echo ” su $ORA_OWNR -c “”$ORACLE_HOME/bin/lsnrctl stop”

su $ORA_OWNR -c “$ORACLE_HOME/bin/lsnrctl stop”

echo ” su $ORA_OWNR -c “”$ORACLE_HOME/bin/dbshut $ORACLE_HOME”

su $ORA_OWNR -c “$ORACLE_HOME/bin/dbshut $ORACLE_HOME”

rm -f /var/lock/oracle

echo “su $ORA_OWNR -c “”$ORACLE_HOME/bin/emctl stop dbconsole”

su $ORA_OWNR -c “$ORACLE_HOME/bin/emctl stop dbconsole”

echo ” Shutdown Oracle ended OK”

;;

reload|restart)

echo “: $1 oracle”

$0 stop

$0 start

;;

*)

echo ” Unknown context: $1″

echo ” Usage: `basename $0` start|stop|restart|reload”

exit 1

esac

exit 0

设置权限,放到启动脚本中去

chmod 755 /etc/init.d/oracledb

update-rc.d oracledb defaults 99

还需要编辑一下/etc/oratab,把其中的N改成Y,不然上述脚本中所调用的$ORACLE_HOME/bin/dbstart在执行时不会自动启动相应的数据库实例(这里的数据库实例是ora1)。文件内容如下:

#

# This file is used by ORACLE utilities. It is created by root.sh

# and updated by the Database Configuration Assistant when creating

# a database.

# A colon, ‘:’, is used as the field terminator. A new line terminates

# the entry. Lines beginning with a pound sign, ‘#’, are comments.

#

# Entries are of the form:

# $ORACLE_SID:$ORACLE_HOME::

#

# The first and second fields are the system identifier and home

# directory of the database respectively. The third filed indicates

# to the dbstart utility that the database should , “Y”, or should not,

# “N”, be brought up at system boot time.

#

# Multiple entries with the same $ORACLE_SID are not allowed.

#

#

ora1:/opt/ora10:Y

我的 oralce 的安装盘中可能有些问题,所以如果只用上述的脚本是不能启动 listener的,要修改一下: 修改 /opt/ora10/bin/dbstart文件 查找:(本步骤修改后需重新安装?——(不需要重新安装呀Sutra 2023年6月10日 (四) 21:31 (CST)))

# Set this to bring up Oracle Net Listener

ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle

将其改为:

# Set this to bring up Oracle Net Listener

ORACLE_HOME_LISTNER=$ORACLE_HOME

设置後,测试一下

/etc/init.d/./oracledb reload

ubuntu数据库下载的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于ubuntu数据库下载,Ubuntu数据库下载:安装教程,求一个能安装在Linux系统Ubuntu 上面的Oracle 10g 64 位 数据库,跪求的信息别忘了在本站进行查找喔。


数据运维技术 » Ubuntu数据库下载:安装教程 (ubuntu数据库下载)