第一部分:jdk6安装 (jdk部分根据javaeye中原文修改而来)
在sun官网下载JDK 6(jdk-6u16-linux-i586.bin);
将软件安装包拷贝至需安装的目录下,修改其可读写属性
拷贝我下载的文件到usr/local/java目录下
[root@oracle ~]# cp -a /home/software/jdk-6u16-linux-i586.bin /usr/local/java
[root@oracle ~]# chmod a+x jdk-6u16-linux-i586-.bin
运行安装 bin 文件。
[root@oracle ~]# ./jdk-6u16-linux-i586-rpm.bin
必须同意它的条款和协议即可一步步安装,输入 yes
设置环境变量(这两条[/etc/profile & /etc/profile.d/java.sh]是定义全局的Java环境变量,若为了安全起见,我们则需要为用户定制安全环境变量,即只设置当前用户下[ .bashrc /注:为绿色的这段代码加入即可]的环境变量)
[root@oracle ~]# vi /etc/profile
# set java environment
JAVA_HOME=/usr/local/java/jdk1.6.0_16
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME PATH CLASSPATH
[root@oracle ~]# vi /etc/profile.d/java.sh
# set java environment
JAVA_HOME=/usr/local/java/jdk1.6.0_16
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME PATH CLASSPATH
保存后设置一下运行权限
[root@oracle ~]# chmod a+x /etc/profile.d/java.sh
最后进行一下链接,使配置生效(建立软连接)
[root@oracle ~]# ln -sf /usr/local/java/jdk1.6.0_16/bin/java /usr/bin/java
[root@oracle ~]# ln -sf /usr/local/java/jdk1.6.0_16/bin/javac /usr/bin/javac
单独为当前用户配置脚本为编辑当前环境下的 .bashrc 文件
[root@oracle ~]# ll -la //此命令即查看当前目录下所有文件,包括隐藏文件
[root@oracle ~]# vi .bashrc
# set java environment
JAVA_HOME=/usr/local/java/jdk1.6.0_16
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME PATH CLASSPATH
(以下source的作用source命令通常用于重新执行刚修改的初始化文件,使之立即生效,而不必注销并重新登录。)
[root@oracle ~]# source .bashrc
[root@oracle ~]# java -version
java version "1.6.0_16"
Java(TM) SE Runtime Environment (build 1.6.0_16-b06)
Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing)
若能看到以上文字,则java安装完毕。一切OK!
若想看到个体环境变量,使用echo命令检查环境变量设置情况。
[root@oracle ~]# echo $JAVA_HOME
[root@oracle ~]# echo $CLASSPATH
[root@oracle ~]# echo $PATH
前期准备:
由于redhat Enterprise 5 中自带一个mysql的版本,如果在安装linux前未选择mysql的安装此步就可跳过,因为我当时安装了现在将其卸载 ,步骤如下:
a. 查找已安装的myslq 版本:
#rpm -qa | grep mysql (注意大小写,如果mysql 不行就换MySQL)
在屏幕上将显示已安装的mysql包名如:mysql-5.0.22-2.1.0.1 ;
b. 将搜索出的包名卸载:(若还有cline端,同上一样删除。)
#rpm -e --nodeps mysql-5.0.22-2.1.0.1 (nodeps表示强制删除)
c. 再次查找该包名,如果没有结果输出则表明已将该版本的mysql卸载了 ;
1、下载MySQL的安装文件
http://dev.mysql.com/downloads/mysql/5.1.html#linux-rhel4-x86-32bit-rpms
安装MySQL需要下面两个文件:
MySQL-server-5.1.40-0.i386.rpm
MySQL-client-5.1.40-0.i386.rpm
打开此网页,下拉网页找到“Linux x86 RPM downloads”项,找到“Server”和“Client programs”项,下载需要的上述两个rpm文件。
2、安装MySQL
rpm文件是Red Hat公司开发的软件安装包,rpm可让Linux在安装软件包时免除许多复杂的手续。该命令在安装时常用的参数是 –ivh ,其中i表示将安装指定的rmp软件包,V表示安装时的详细信息,h表示在安装期间出现“#”符号来显示目前的安装过程。这个符号将持续到安装完成后才停止。
1)安装服务器端
在有两个rmp文件的目录下运行如下命令:
[root@test1 local]# rpm -ivh MySQL-server-5.1.40--0.i386.rpm
显示如下信息。
warning: MySQL-server-5.1.40--0.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
Preparing... ########################################### [100%]
1:MySQL-server ########################################### [100%]
... ...(省略显示)
/usr/bin/mysqladmin -u root password \'new-password\'
/usr/bin/mysqladmin -u root -h test1 password \'new-password\'
... ...(省略显示)
Starting mysqld daemon with databases from /var/lib/mysql
如出现如上信息,服务端安装完毕。测试是否成功可运行netstat看Mysql端口是否打开,如打开表示服务已经启动,安装成功。Mysql默认的端口是3306。
[root@test1 local]# netstat -nat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
上面显示可以看出MySQL服务已经启动。
2)安装客户端
运行如下命令:
[root@test1 local]# rpm -ivh MySQL-client-5.1.40--0.i386.rpm
warning: MySQL-client-5.1.40--0.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
Preparing... ########################################### [100%]
1:MySQL-client ########################################### [100%]
显示安装完毕。
用下面的命令连接mysql,测试是否成功。
三、登录MySQL
登录MySQL的命令是mysql, mysql 的使用语法如下:
mysql [-u username] [-h host] [-p[password]] [dbname]
username 与 password 分别是 MySQL 的用户名与密码,mysql的初始管理帐号是root,没有密码,注意:这个root用户不是Linux的系统用户。MySQL默认用户是root,由于初始没有密码,第一次进时只需键入mysql即可。
[root@test1 local]# mysql
Welcome to the MySQL monitor. Commands end with ; or \\g.
Your MySQL connection id is 1 to server version: 4.0.16-standard
Type \'help;\' or \'\\h\' for help. Type \'\\c\' to clear the buffer.
mysql>
出现了“mysql>”提示符,恭喜你,安装成功!
增加了密码后的登录格式如下:
mysql -u root -p
Enter password: (输入密码)
其中-u后跟的是用户名,-p要求输入密码,回车后在输入密码处输入密码。
注意:这个mysql文件在/usr/bin目录下,与后面讲的启动文件/etc/init.d/mysql不是一个文件。
四、MySQL的几个重要目录
MySQL安装完成后不象SQL Server默认安装在一个目录,它的数据库文件、配置文件和命令文件分别在不同的目录,了解这些目录非常重要,尤其对于Linux的初学者,因为 Linux本身的目录结构就比较复杂,如果搞不清楚MySQL的安装目录那就无从谈起深入学习。
下面就介绍一下这几个目录。
1、数据库目录
/var/lib/mysql/
2、配置文件
/usr/share/mysql(mysql.server命令及配置文件)
3、相关命令
/usr/bin(mysqladmin mysqldump等命令)
4、启动脚本
/etc/rc.d/init.d/(启动脚本文件mysql的目录)
五、修改登录密码
MySQL默认没有密码,安装完毕增加密码的重要性是不言而喻的。
1、命令
usr/bin/mysqladmin -u root password \'new-password\'
格式:mysqladmin -u用户名 -p旧密码 password 新密码
2、例子
例1:给root加个密码123456。
键入以下命令 :
[root@test1 local]# /usr/bin/mysqladmin -u root password 123456
注:因为开始时root没有密码,所以-p旧密码一项就可以省略了。
3、测试是否修改成功
1)不用密码登录
[root@test1 local]# mysql
ERROR 1045: Access denied for user: \'root@localhost\' (Using password: NO)
显示错误,说明密码已经修改。
2)用修改后的密码登录
其他:
1、授权
Assuming you have MySQL installed and running with a password for the root mysql user, you can perform the linux side of the MySQL setup entirely from the command-line with the following:
$ mysql -u root -p;
CREATE DATABASE <dbname>;
GRANT ALL PRIVILEGES ON <dbname>.* TO 'confluenceuser'@'<hostname>' IDENTIFIED BY '<password>';
你想授权出去的数据库
FLUSH PRIVILEGES;授权后要刷新
2、关于linux中mysql中编码的问题(UTF-8)
不管什么时候,编码一定要统一,这是保证数据能正确入库的前提。首先要配置你的mysql的默认编码方式为UTF-8.
具体看my.cnf的配置.
(#cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf)
下面是很重要的=====================================拷贝后增加红色编辑三行。
[client]
#password = your_password
port = 3306
socke /tmp/mysql.sock
default-character-set = utf8
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-locking
key_buffer = 16M
max_allowed_packet = 1M
default-storage-engine = InnoDB
table_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
default-character-set = utf8
当你配置好了以后,重启mysql 进入mysql,执行#status,可以看到以下结果。
--------------
mysql Ver 14.12 Distrib 5.0.41, for pc-linux-gnu (i686) using readline 5.0
Connection id: 1
Current database: jsp
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.0.41-log MySQL Community Server (GPL)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /tmp/mysql.sock
Uptime: 1 hour 12 min 21 sec
Threads: 2 Questions: 390 Slow queries: 0 Opens: 18 Flush tables: 1 Open tables: 8 Queries per second avg: 0.090
--------------
这就说明mysql编码方式为UTF-8.
CREATE
DATABASE
confluence
CHARACTER
SET
utf8
COLLATE
utf8_bin;)
5、Next Step is the Confluence Setup Wizard
The Confluence Setup Wizard should appear in your web browser, prompting you to enter your license key. Follow the instructions on the screens, and read more guidelines on the Confluence Setup Wizard.