[root@localhost mysql]# chown -R root:mysql /opt/mysql
[root@localhost mysql]# chown -R mysql /opt/mysql/var/ 优化执行路径、程序库路径:
[root@localhost mysql]# ln -s /opt/mysql/bin/* /usr/local/bin/
[root@localhost mysql]# ln -s /opt/mysql/lib/mysql/* /usr/lib/
[root@localhost mysql]# ln -s /opt/mysql/include/mysql/* /usr/include/ 添加mysql为系统服务:
[root@localhost mysql]# cp /usr/src/mysql-5.1.55/support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql]# chmod +x /etc/init.d/mysqld
[root@localhost mysql]#chkconfig --add mysqld ##添加为系统服
[root@localhost mysql]# /etc/init.d/mysqld start ##启动服务 设置mysql的字符集:
[root@localhost ~]# vi /etc/my.cnf
default-character-set=utf8 ##将这一项添加到【msyql】【mysqld】模块中
[root@localhost ~]#/etc/init.d/mysqld restart ##重启mysql 使用mysql:
[root@localhost ~]# mysqladmin -uroot password ‘123123’ ##mysql数据库root的密码为123123
[root@localhost ~]# mysqldump -uroot -p123123 --all-databases >mysql.sql ##备份mysql
[root@localhost ~]# mysql -uroot -p123123 d:
D:\>pscp dc dc.sql root@192.168.8.49:/opt/tomcat7/webapps/
导入项目数据:
[root@localhost bin]# mysql -uroot –p123123 ##登录mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 217
Server version: 5.1.55-log Source distribution
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database dc; ##创项目数据库
mysql>quit
[root@localhost bin]# mysql -uroot -p123123 --databases dc< dc.sql ##导入项目数据
[root@localhost bin]# service mysqld restart ##重启mysql 修改项目数据库密码:此处视特定项目而定、与研发人员沟通确认
[root@localhost bin]# vi /opt/tomcat7/webapps/dc/WEB-INF/web.xml
This is the description of my J2EE component
This is the display name of my J2EE component
ControlServelet
action.ControlServelet
driverString
com.mysql.jdbc.Driver
urlString
jdbc:mysql://127.0.0.1:3306/dc
username
root
password
123123
excelpath
/var/lib/tomcat6/webapps/dc/biao/
jsppath
/var/lib/tomcat6/webapps/dc/
1
[root@localhost ~]# /opt/tomcat7/bin ##重启tomcat
[root@localhost bin]# ./shutdown.sh ##停止tomcat
Using CATALINA_BASE: /opt/tomcat7
Using CATALINA_HOME: /opt/tomcat7
Using CATALINA_TMPDIR: /opt/tomcat7/temp
Using JRE_HOME: /opt/jdk/
Using CLASSPATH: /opt/tomcat7/bin/bootstrap.jar:/opt/tomcat7/bin/tomcat-juli.jar
[root@localhost bin]# ./startup.sh ##启动tomcat
Using CATALINA_BASE: /opt/tomcat7
Using CATALINA_HOME: /opt/tomcat7
Using CATALINA_TMPDIR: /opt/tomcat7/temp
Using JRE_HOME: /opt/jdk/
Using CLASSPATH: /opt/tomcat7/bin/bootstrap.jar:/opt/tomcat7/bin/tomcat-juli.jar
4. 测试验证
在浏览器中访问测试,访问时注意iptables、及selinux的限制,可以将其关闭,等测试无误后在做调整
[root@localhost ~]# setenforce 0 ##设置selinux的状态为允许、默认是1为强制限制
[root@localhost ~]# /etc/init.d/iptables stop ##关闭防火墙
Tomcat默认使用8080端口、但是上文已经改为80端口,直接输入ip加项目名即可,如图: