Linux系统(X64)安装Oracle11g完整安装图文教程另附基本操作

一、修改操作系统核心参数

在Root用户下执行以下步骤:

1)修改用户的SHELL的限制,修改/etc/security/limits.conf文件

输入命令:vi /etc/security/limits.conf,按i键进入编辑模式,将下列内容加入该文件。

oracle soft nproc 2047

oracle hard nproc 16384

oracle soft nofile 1024

oracle hard nofile 65536

编辑完成后按Esc键,输入“:wq”存盘退出

2)修改/etc/pam.d/login 文件,输入命令:vi /etc/pam.d/login,按i键进入编辑模式,将下列内容加入该文件。

session required /lib/security/pam_limits.so

session required pam_limits.so

编辑完成后按Esc键,输入“:wq”存盘退出

3)修改linux内核,修改/etc/sysctl.conf文件,输入命令: vi /etc/sysctl.conf ,按i键进入编辑模式,将下列内容加入该文件

fs.file-max = 6815744

fs.aio-max-nr = 1048576

kernel.shmall = 2097152

kernel.shmmax = 2147483648

kernel.shmmni = 4096

kernel.sem = 250 32000 100 128

net.ipv4.ip_local_port_range = 9000 65500

net.core.rmem_default = 4194304

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048576

编辑完成后按Esc键,输入“:wq”存盘退出

4)要使 /etc/sysctl.conf 更改立即生效,执行以下命令。 输入:sysctl -p 显示如下:

linux:~ # sysctl -p

net.ipv4.icmp_echo_ignore_broadcasts = 1

net.ipv4.conf.all.rp_filter = 1

fs.file-max = 6815744

fs.aio-max-nr = 1048576

kernel.shmall = 2097152

kernel.shmmax = 2147483648

kernel.shmmni = 4096

kernel.sem = 250 32000 100 128

net.ipv4.ip_local_port_range = 9000 65500

net.core.rmem_default = 4194304

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048576

5)编辑 /etc/profile ,输入命令:vi /etc/profile,按i键进入编辑模式,将下列内容加入该文件。

if [ $USER = "oracle" ]; then

if [ $SHELL = "/bin/ksh" ]; then

ulimit -p 16384

ulimit -n 65536

else

ulimit -u 16384 -n 65536

fi

fi

编辑完成后按Esc键,输入“:wq”存盘退出

6)创建相关用户和组,作为软件安装和支持组的拥有者。

创建Oracle用户和密码,输入命令:

useradd -g oinstall -g dba -m oracle

passwd oracle

然后会让你输入密码,密码任意输入2次,但必须保持一致,回车确认。

7)创建数据库软件目录和数据文件存放目录,目录的位置,根据自己的情况来定,注意磁盘空间即可,这里我把其放到oracle用户下,例如:

输入命令:

mkdir /home/oracle/app

mkdir /home/oracle/app/oracle

mkdir /home/oracle/app/oradata

mkdir /home/oracle/app/oracle/product

8)更改目录属主为Oracle用户所有,输入命令:

chown -R oracle:oinstall /home/oracle/app

9)配置oracle用户的环境变量,首先,切换到新创建的oracle用户下,

输入:su – oracle ,然后直接在输入 : vi .bash_profile

按i编辑 .bash_profile,进入编辑模式,增加以下内容:

export ORACLE_BASE=/home/oracle/app

export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1

export ORACLE_SID=orcl

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

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib

编辑完成后按Esc键,输入“:wq”存盘退出

二、安装过程

1)当上述系统要求操作全部完成后,注销系统,在图形界面以Oracle用户登陆。首先将下载的Oracle安装包复制到linux中,用SSH其他ftp工具拷贝。

打开一个终端,运行unzip命令解压oracle安装文件,如:

输入命令:

unzip linux.x64_11gR2_database_1of2.zip

unzip linux.x64_11gR2_database_2of2.zip

解压完成后 cd 进入其解压后的目录database

输入命令:

cd database

使用ls命令可以查看解压后database所包含的文件,如下图:

2)执行安装,输入命令:./runInstaller

装到这一步,可以看到,可以查看到有很多的rpm包没有,我们可以从安装linux的光盘或ISO中(或去D:\linux_oracle11g_Package)查找所缺的包,使用ftp上传到linux中,然后使用rpm –ivh xxx.rpm –nodeps –force 来进行安装(其中加上–nodeps — force 代表强制安装,是在直接使用rpm –ivh xxx.rpm安装不成功的情况下用的)等到把包全部都安装好的情况下,再次在oracle图形界面中,执行安装过程2,下来在环境检查过程中,就通过了。

安装过程中86%可能会遇到报错如出错问题(error in invoking target \\’mkldflags ntcontab.o nnfgt.o\\’ of makefile)按照如下步骤顺序执行。

上传安装镜像rhel-server-6.1-x86_64-dvd.iso,

然后将镜像文件挂,如/mnt

# mount -o loop rhel-server-6.1-x86_64-dvd.iso /mnt

# cd /mnt/Packages

# rpm -ivh glibc-common-2.12-1.25.el6.x86_64.rpm

# rpm -ivh kernel-headers-2.6.32-131.0.15.el6.x86_64.rpm

# rpm -ivh libgcc-4.4.5-6.el6.x86_64.rpm

# rpm -ivh glibc-2.12-1.25.el6.x86_64.rpm

# rpm -ivh libgomp-4.4.5-6.el6.x86_64.rpm

# rpm -ivh nscd-2.12-1.25.el6.x86_64.rpm

# rpm -ivh glibc-headers-2.12-1.25.el6.x86_64.rpm

# rpm -ivh glibc-devel-2.12-1.25.el6.x86_64.rpm

# rpm -ivh mpfr-2.4.1-6.el6.x86_64.rpm

# rpm -ivh ppl-0.10.2-11.el6.x86_64.rpm

# rpm -ivh cloog-ppl-0.15.7-1.2.el6.x86_64.rpm

# rpm -ivh cpp-4.4.5-6.el6.x86_64.rpm

# rpm -ivh gcc-4.4.5-6.el6.x86_64.rpm

注:以上是安装gcc,软件安装顺序不能错。

******************************************

# rpm -ivh libstdc  -4.4.5-6.el6.x86_64.rpm

# rpm -ivh libstdc  -devel-4.4.5-6.el6.x86_64.rpm

# rpm -ivh gcc-c  -4.4.5-6.el6.x86_64.rpm

注:以上是安装gcc-c

根据这个方法解决了错误。

安装完成后,系统会提示你需要用root权限执行2个shell脚本。按照其提示的路径,找到其所在的位置,如:我的就在/home/oracle/app/oracle/product/11.2.0/dbhome_1/root.sh

和 /home/oracle/oraInventory/orainstRoot.sh 新开启一个终端,输入命令:

su – root

cd /home/oracle/app/oracle/product/11.2.0/dbhome_1

sh root.sh

cd /home/oracle/oraInventory

sh orainstRoot.sh

三、数据库建库

1) 还是在oracle用户的图形界面oracle用户中,新开启一个终端,直接输入命令dbca会弹出如下界面。我们这里采用定制数据库。

经过漫长的等待,当看到此界面,说明oracle建库完成

四、配置监听及本地网络服务

1)在oracle用户的图形界面oracle用户中,新开启一个终端,输入命令netca 会弹出如下界面。

2)创建监听服务(充当oracle服务器,让别的oracle客户端连接本oracle服务器)

3) 配置本地网络服务名(充当oracle客户端,连接别的oracle服务器)

输入连接的oracle服务器的数据库的实例名

输入oracle服务器的ip地址

选中YES测试

点击change Login 输入所连接oracle服务器的其中某一个用户名和密码(用户名oracle和设置的密码),点击OK

看到此界面说明测试成功(如果不成功,请查看网络是否畅通,所连接的oracle服务器是否启动,监听是否启动等原因)

为你所设置的本地网络服务名起个名字

这样oracle服务器安装配置基本就完成了

注意:

1、Linux oracle数据库listener.ora存放路径

cd /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

2、Linux oracle数据库tnsnames.ora存放路径

cd /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora

3、ORACLE启动监听器
(1)切换至oracle安装用户(一般为oracle)
su – oracle
(2)启动监听器
lsnrctl start
(3)停止监听器
lsnrctl stop

4、启动测试oracle:
[oracle@oracle ~]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on Fri Jul 27 02:12:12 2012
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> quit
测试的另一种方法:找一台windows平台电脑,telnet oracle主机IP地址:1521,通的话,会出现一个黑屏,光标一闪一闪。

5、Linux开放1521端口允许网络连接Oracle Listener

症状:
(1)TCP/IP连接是通的。可以用ping 命令测试。
(2)服务器上Oracle Listener已经启动。
lsnrctl status 查看listener状态
lsnrctl start 启动Oracle listener
(3)客户端得到的错误信息通常是:ORA-12170: TNS:连接超时
这时,我们基本可以肯定是服务器没有开放1521端口(假设你用默认设置)

解决方法:
(1)假如你是在一个局域网环境,配置了防火墙。那么可以关闭Linux的防火墙。
sudo service iptables stop
(2)编辑iptables, 开放1521端口:
sudo vi /etc/sysconfig/iptables
-A INPUT -p tcp -m state –state NEW -m tcp –dport 1521 -j ACCEPT
:wq

重启防火墙
sudo service iptables restart
保存配置,以便linux重启后依然有效
sudo service iptables save
查看防火墙规则:
sudo iptables -L –n

6、linux下创建oracle用户表空间

就是在已有的数据库实例上创建一个新的帐号,访问一些新的表
操作步骤如下:
(1)登录linux,以oracle用户登录(如果是root用户登录的,登录后用 su – oracle命令切换成oracle用户)
(2)以sysdba方式来打开sqlplus,命令如下: sqlplus “/as sysdba”
(3)查看我们常规将用户表空间放置位置:执行如下sql:
select name from v$datafile
(4)创建用户表空间:
CREATE TABLESPACE NOTIFYDB DATAFILE \\’/home/oracle/app/oradata/orcl/scsdb.dbf\\’ SIZE 200M AUTOEXTEND ON EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;
(5)创建用户,指定密码和上边创建的用户表空间
CREATE USER scs IDENTIFIED BY scs DEFAULT TABLESPACE NOTIFYDB;
(6)赋予权限
grant connect,resource to scs;
grant unlimited tablespace to scs;
grant create database link to scs;
grant select any sequence,create materialized view to scs;
–经过以上操作,我们就可以使用scs/scs登录指定的实例,创建我们自己的表了

nginx 反向代理配置

[code lang=”text”]
location / {
root /date/wwwroot/linuxtone/;
proxy_redirect off ;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 50m;
client_body_buffer_size 256k;
proxy_connect_timeout 30;
proxy_send_timeout 30;
proxy_read_timeout 60;
proxy_buffer_size 256k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;
proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
proxy_max_temp_file_size 128m;
proxy_pass http://bbs.linuxtone.com;
}
[/code]

http://liuyu.blog.51cto.com/183345/166381/

在linux命令行安装oracle11g centos系统

http://space.itpub.net/21582653/viewspace-716034

 

在linux命令行安装oracle11g

 

一:环境设置

1.1  检查服务器硬件资源

Linux系统(x86-32)下的硬件要求

物理内存:最少1GB

交互空间:物理内存为1GB至2GB之间时,交互空间为物理内存的1.5倍;物理内存为2GB至8GB之间时,交互空间为物理内存的1倍;物理内存为8GB以上时,交互空间为物理内存的0.75倍。

磁盘空间:企业版4.35GB;标准版3.22GB;自定义(最大值):3.45GB

1.2  操作系统环境设置

X86(32位)Red Hat Enterise 5.0、CentOS5.0需要的安装包:

binutils-2.17.50.0.6-14.el5

elfutils-libelf-0.137-3.el5

elfutils-libelf-devel-0.137-3.el5

gcc-4.1.2-50.el5

gcc-c++-4.1.2-50.el5

glibc-2.5-58.el5_6.4

glibc-common-2.5-58.el5_6.4

glibc-devel-2.5-58.el5_6.4

glibc-headers-2.5-58.el5_6.4

libaio-devel-0.3.106-5

libaio-0.3.106-5

libgcc-4.1.2-50.el5

libstdc++-4.1.2-50.el5

libstdc++-devel-4.1.2-50.el5

make-3.81-3.el5

sysstat-7.0.2-3.el5

unixODBC-2.2.11-7.1

unixODBC-devel-2.2.11-7.1

1.3  内核参数设置

将以下参数设置加入/etc/sysctl.conf中,这样每次操作系统启动时,便会自动设置这些内核参数,而不需要每次都人工设置。

# vi /etc/sysctl.conf

fs.file-max = 6553600

kernel.shmall = 2097152

kernel.shmmax = 2147483648

kernel.shmmni = 4096

kernel.sem = 250 32000 100 128

net.ipv4.ip_local_port_range = 1024 65000

net.core.rmem_default = 4194304

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 262144

 

使用sysctl –p命令使/etc/sysctl.conf设置值生效。

1.4  设置系统资源限制

假设未来由oracle这个系统用户安装Orace Database 11g,则系统管理员需要将以下参数添加到/etc/security/limits.conf中

# vi /etc/security/limits.conf

oracle soft nproc 2047

oracle hard nproc 16384

oracle soft  nofile 1024

oracle hard  nofile 65536

 

接着,设置/etc/pam.d/login,启动系统资源限制。

# vi /etc/pam.d/login

session required  /lib/security/pam_limits.so

session required  pam_limits.so

 

最后,为了能让每个用户在每次登陆系统之后,都能自动设置其最大可启动进程数与最多可开启文件数,设置/etc/profile。

# vi /etc/profile

if [ $USER = “oracle” ] ; then

if [ $SHELL = “/bin/ksh” ]; then

ulimit –p 16384

ulimit -n 65536

else

ulimit –u 16384 -n 65536

fi

fi

 

 

1.5  网络设置

安装oracle database 11g的服务器必须有固定的IP地址。

 

1.6  创建用户组与用户账户

# groupadd oinstall

#groupadd  dba

#groupadd  oper

#useradd -g oinstall -G  dba,oper oracle

#passwd oracle

 

设置用户环境变量

将下列设置添加到/home/oracle/.bash_profile文件中

# vi  /home/oracle/.bash_profile

umask 022

ORACLE_BASE=/u01/app/oracle

ORACLE_HOME=$ORACLE_BASE/product/11.1.0/db_1

ORACLE_SID=orcl

PATH=$ORACLE_HOME/bin:$PATH

export PATH

export ORACLE_BASE ORACLE_HOME ORACLE_SID

export NLS_LANG=”SIMPLIFIED CHINESE_CHINA.ZHS16GBK”

 

设置安装路径

# mkdir -p /home/u01/app/oracle/product/11.1.0

# mkdir -p /home/u01/oradata

#chmod -R 775 /home/u01

#chown  -R oracle.oinstall /home/u01

 

二、安装Oracle Database  11g R1

把orace database 11g r1 的安装包下载到oracle用户的家目录解压,解压后的文件夹为database

# unzip  linux_11gR1_database_1013.zip

 

修改静默安装的应答文件

# vi database/install/response/ee.rsp

ORACLE_BASE=”/home/u01/app”

ORACLE_HOME=”/home/u01/app/oracle/product/11.1.0/db_1″

ORACLE_HOME_NAME=”orarch”

 

切换为oracle用户,以静默方式执行安装脚本,在安装过程中如果没有错误不会有信息输出,最后会输出请运行root.sh脚本的信息。

# su – oracle

$cd  database

$ ./runInstaller -responseFile /home/oracle/linux_11gR1/database/install/response/ee.rsp –silent

 

输出请运行root.sh脚本的信息时,打开另一个终端以root身份运行/home/u01/app/oracle/product/11.1.0/db_1脚本。

运行完root.sh脚本后在安装的终端中回车既完成安装。

使MySQL对表名不区分大小写

LINUX下的MYSQL默认是要区分表名大小写的,所以很可能在windows运行好好的系统,放到Linux上就会报找不到表的错误

让MYSQL不区分表名大小写的方法其实很简单:

1.用ROOT登录,修改/etc/my.cnf

2.在[mysqld]下加入一行:lower_case_table_names=1

3.重新启动数据库即可

MySql实现远程连接

前提:

1、进入mysql,创建一个新用户root,密码为root:

格式:grant 权限 on 数据库名.表名 to 用户@登录主机 identified by “用户密码”;
grant select,update,insert,delete on *.* to root@192.168.1.12 identified by “root”;

原先数据表结构

mysql> use mysql;
Database changed
mysql> select host,user,password from user;
+———–+——+——————————————-+
| host      | user | password                                  |
+———–+——+——————————————-+
| localhost | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+———–+——+——————————————-+

执行上述语句后结果

mysql> use mysql;
Database changed
mysql> select host,user,password from user;
+————–+——+——————————————-+
| host         | user | password                                  |
+————–+——+——————————————-+
| localhost    | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| 192.168.1.12 | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+————–+——+——————————————-+
2 rows in set (0.00 sec)

 

可以看到在user表中已有刚才创建的root用户。host字段表示登录的主机,其值可以用IP,也可用主机名,

(1)有时想用本地IP登录,那么可以将以上的Host值改为自己的Ip即可。

2、实现远程连接(授权法)

将host字段的值改为%就表示在任何客户端机器上能以root用户登录到mysql服务器,建议在开发时设为%。
update user set host = ’%’ where user = ’root’;

将权限改为ALL PRIVILEGES

mysql> use mysql;
Database changed
mysql> grant all privileges  on *.* to root@’%’ identified by “root”;
Query OK, 0 rows affected (0.00 sec)

mysql> select host,user,password from user;
+————–+——+——————————————-+
| host         | user | password                                  |
+————–+——+——————————————-+
| localhost    | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| 192.168.1.12 | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| %            | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+————–+——+——————————————-+
3 rows in set (0.00 sec)

这样机器就可以以用户名root密码root远程访问该机器上的MySql.

3、实现远程连接(改表法)

use mysql;

update user set host = ‘%’ where user = ‘root’;

这样在远端就可以通过root用户访问Mysql.

 

总结:第一种方法就是修改表的数据

centos6.4 MySQL 5.5 安装过程

MySQL is a relational database management system (RDBMS) that runs as a server providing multi-user access to a number of databases. This is guide, howto install or upgrade MySQL Community Server latest and greatest version 5.5.33 on Fedora 18/17/16/15/14/13/12, CentOS 6.4/6.3/6.2/6.1/6/5.9 and Red Hat (RHEL) 6.4/6.3/6.2/6.1/6/5.9.

Note: If you are upgrading MySQL (from earlier version), then make sure that you backup (dump and copy) your database and configs. And remember run mysql_upgrade command.

Install MySQL Database 5.5.33 on Fedora 18/17/16/15/14/13/12, CentOS 6.4/5.9, Red Hat (RHEL) 6.4/5.9

1. Change root user

su -
## OR ##
sudo -i

2. Install Remi repository

Fedora

## Remi Dependency on Fedora 18, 17, 16
rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm 
rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm

## Fedora 18 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-18.rpm

## Fedora 17 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-17.rpm

## Fedora 16 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-16.rpm

## Fedora 15 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-15.rpm

## Fedora 14 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-14.rpm

## Fedora 13 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-13.rpm

## Fedora 12 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-12.rpm

CentOS and Red Hat (RHEL)

## Remi Dependency on CentOS 6 and Red Hat (RHEL) 6 ##
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

## CentOS 6 and Red Hat (RHEL) 6 ##
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

## Remi Dependency on CentOS 5 and Red Hat (RHEL) 5 ##
rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

## CentOS 5 and Red Hat (RHEL) 5 ## 
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm

3. Check Available MySQL versions

Fedora 18, 17, 16, 15, 14, 13, 12

yum --enablerepo=remi list mysql mysql-server

CentOS 6.4/6.3/6.2/6.1/6/5.9 and Red Hat (RHEL) 6.4/6.3/6.2/6.1/6/5.9

yum --enablerepo=remi,remi-test list mysql mysql-server

Output:

Loaded plugins: changelog, fastestmirror, presto, refresh-packagekit
...
remi                                                            | 3.0 kB     00:00     
remi/primary_db                                                 | 106 kB     00:00     
Available Packages
mysql.i686                               5.5.33-1.fc18.remi                        @remi
mysql-server.i686                        5.5.33-1.fc18.remi                        @remi

4. Update or Install MySQL 5.5.33

Fedora 18, 17, 16, 15, 14, 13, 12

yum --enablerepo=remi install mysql mysql-server

CentOS 6.4/6.3/6.2/6.1/6/5.9 and Red Hat (RHEL) 6.4/6.3/6.2/6.1/6/5.9

yum --enablerepo=remi,remi-test install mysql mysql-server

5. Start MySQL server and autostart MySQL on boot

Fedora 18/17/16

systemctl start mysqld.service ## use restart after update

systemctl enable mysqld.service

Fedora 15/14/13/12/11, CentOS 6.4/6.3/6.2/6.1/6/5.9 and Red Hat (RHEL) 6.4/6.3/6.2/6.1/6/5.9

/etc/init.d/mysqld start ## use restart after update
## OR ##
service mysqld start ## use restart after update

chkconfig --levels 235 mysqld on

6. MySQL Secure Installation

  • Set (Change) root password
  • Remove anonymous users
  • Disallow root login remotely
  • Remove test database and access to it
  • Reload privilege tables

Start MySQL Secure Installation with following command

/usr/bin/mysql_secure_installation

Output:

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we\'ll need the current
password for the root user.  If you\'ve just installed MySQL, and
you haven\'t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] Y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
 ... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!

Cleaning up...

All done!  If you\'ve completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

Note: If you don’t want some reason, do a “MySQL Secure Installation” then at least it’s very important to change the root user’s password

mysqladmin -u root password [your_password_here]

## Example ##
mysqladmin -u root password myownsecrectpass

7. Connect to MySQL database (localhost) with password

mysql -u root -p

## OR ##
mysql -h localhost -u root -p

8. Create Database, Create MySQL User and Enable Remote Connections to MySQL Database

This example uses following parameters:

  • DB_NAME = webdb
  • USER_NAME = webdb_user
  • REMOTE_IP = 10.0.15.25
  • PASSWORD = password123
  • PERMISSIONS = ALL
## CREATE DATABASE ##
# CREATE DATABASE db_name DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
mysql> CREATE DATABASE webdb;

## CREATE USER ##
mysql> CREATE USER 'webdb_user'@'10.0.15.25' IDENTIFIED BY 'password123';

## GRANT PERMISSIONS ##
mysql> GRANT ALL ON webdb.* TO 'webdb_user'@'10.0.15.25';

##  FLUSH PRIVILEGES, Tell the server TO reload the GRANT TABLES  ##
mysql> FLUSH PRIVILEGES;

Enable Remote Connection to MySQL Server –> Open MySQL Port (3306) on Iptables Firewall (as root user again)

1. Edit /etc/sysconfig/iptables file:

nano -w /etc/sysconfig/iptables

2. Add following INPUT rule:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

3. Restart Iptables Firewall:

service iptables restart
## OR ##
/etc/init.d/iptables restart

4. Test remote connection:

mysql -h dbserver_name_or_ip_address -u webdb_user -p webdb

undo表空间大小估算

Oracle的官方文档中给出Undo表空间的大小可以用下面的公式来估算:

select (UR * (UPS * DBS)) + (DBS * 24) as "Bytes"

from (select value as UR from v$parameter where name = 'undo_retention'),

(select (sum(undoblks) / sum(((end_time - begin_time) * 86400))) as UPS
from v$undostat),
(select value as DBS from v$parameter where name = 'db_block_size')