Centos6.4 install and configure JDK + TOMCAT + MYSQL tutorial CentOS6CentOSTomcatJDK
I. system environment and software packages
[Root @ localhost/] # uname-r
2.6.32-358. el6.x86 _ 64
[Root @ localhost/] # cat/etc/centos-release
CentOS release 6.4 (Final)
Software package
Jdk-6u43-linux-x64-rpm.bin
Apache-tomcat-6.0.36.tar.gz
Mysql-5.5.23.tar.gz
II. installation and configuration
1. JDK
First, check whether the built-in JDK of centos is installed. run the java-version command. if the following information is displayed:
Java version "1.6.0 ″
OpenJDK Runtime Environment (build 1.6.0-b09)
OpenJDK 64-Bit Server VM (build 1.6.0-b09, mixed mode)
It indicates that openjdk1.6 has been installed. this package has limited functions. you 'd better uninstall openjdk first and then install sun's jdk.
The uninstall process is simple.
Rpm-e-nodeps java-1.4.2-gcj-compat-1.4.2.0-40jpp. 115 rpm-e-nodeps java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5
Or
Yum-y remove java java-1.4.2-gcj-compat-1.4.2.0-40jpp.115 yum-y remove java java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5
Install SUN's JDK
Chmod a + x jdk-6u43-linux-x64-rpm.bin./jdk-6u43-linux-x64-rpm.bin (path default on/usr/java) java-version
Java version "1.6.0 _ 43"
Java SE Runtime Environment (build 1.6.0 _ 43-b01)
Java HotSpot 64-Bit Server VM (build between 14-b01, mixed mode)
2. install TOMCAT
Put the TOMCAT package under/usr/tomcat
Tar-zxvf apache-tomcat-6.0.36.tar.gz mv apache-tomcat-6.0.36.tar.gz tomcat
After installation, set the environment variable.
Add the following statement to vi/etc/profile:
JAVA_HOME =/usr/java/jdk1.6.0 _ 43
CLASSPATH =.: $ JAVA_HOME/jre/lib/rt. jar: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar
PATH = $ PATH: $ JAVA_HOME/bin
Export path classpath JAVA_HOME
Export CATALINA_BASE =/usr/tomcat
Export CATALINA_HOME =/usr/tomcat
Source/etc/profile (for environment variables to take effect)
Start TOMCAT
Cd bin./startup. sh
Using CATALINA_BASE:/usr/tomcat
Using CATALINA_HOME:/usr/tomcat
Using CATALINA_TMPDIR:/usr/tomcat/temp
Using JRE_HOME:/usr/java/jdk1.6.0 _ 43
Using CLASSPATH:/usr/tomcat/bin/bootstrap. jar
[Root @ localhost bin] # netstat-an | grep: 8080
Tcp 0 0: 8080: * LISTEN
3. mysql
The new version of mysql 5.x usually requires cmake compilation and installation. here we install mysql 5.5.23. here we record the installation steps and procedures of CMAKE for future reference.
If a missing toolkit is found during compilation and installation, use yum install to download and install it separately and then continue.
The following installation involves several issues that need to be explained in advance:
Mysql will be installed in the/usr/local/mysql/Directory
Mysql uses the utf8 character set by default.
Mysql data and log files are stored in the/var/mysql/directory.
The mysql configuration file is saved in/etc/my. cnf
Configure and install
Useradd mysql passwd mysql groupadd mysql useradd-g mysql mkdir-p/usr/local/mysql mkdir-p/var/mysql/data chown-R mysql: mysql/usr/local/mysql chmod-R 755/usr/local/mysql chown-R mysql: mysql/var/mysql chmod-R 755/var/mysql yum-y install cmake bison ncurses-devel gcc-c ++ libstdc ++
(Local YUM source or external image source can be configured)
Tar zxvf mysql-5.5.23.tar.gz cd mysql-5.5.23 cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql-DMYSQL_UNIX_ADDR =/tmp/mysql. sock-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = utf8_general_ci-DWITH_EXTRA_CHARSETS: STRING = utf8, gbk-DWITH_MYISAM_STORAGE_ENGINE = 1-DWITH_INNOBASE_STORAGE_ENGINE = 1-DWITH_READLINE = 1-DENABLED_LOCAL_INFILE = 1-DMYSQL_DATADIR =/var/mysql/data
If an error occurs during installation
Clear cache:
Make clean
Rm CMakeCache.txt
Continue
Make & make install ln-s/usr/local/mysql/lib/libmysqlclient. so.16/usr/lib/libmysqlclient. so.16 cd/usr/local/mysql/support-files/cp my-large.cnf/etc/my. cnf (note: my-large.cnf for 1G memory around the server, you can choose according to their own configuration of my-large.cnf or my-huge.cnf and other different configurations)
Then vi/etc/my. cnf
Edit the configuration file and add it in the [mysqld] section.
Datadir =/var/mysql/data # add the MySQL database path
Go to the scripts directory and run
./Mysql_install_db-defaults-file =/etc/my. cnf-basedir =/usr/local/mysql-datadir =/var/mysql/data-user = mysql
Installing MySQL system tables...
OK
Filling help tables...
OK
In this way, the mysql system database is generated.
Then set the MYSQL service
Cp./support-files/mysql. server/etc/init. d/mysqld # Add Mysql to the system to start
Chmod a + x/etc/init. d/mysqld # Add execution permission
Chkconfig-add mysqld
Chkconfig-level 345 mysqld on
Vi/etc/init. d/mysqld # Edit
Basedir =/usr/local/mysql # MySQL installation path
Datadir =/var/mysql/data # MySQl database storage directory
[Root @ localhost data] # service mysqld start
Starting MySQL... SUCCESS!
[Root @ localhost data] # Net stat-an | grep 3306
Tcp 0 0 0.0.0.0: 3306 0.0.0.0: * LISTEN
At this point, mysql installation is complete!
Add the mysql service to the system environment variable in/etc/profile, and add the following line at the end.
Export PATH = $ PATH:/usr/local/mysql/bin
The following two lines link the myslq library file to the default system location, so that you do not need to specify the mysql library file address when compiling software such as PHP.
Ln-s/usr/local/mysql/lib/mysql/usr/lib/mysql
Ln-s/usr/local/mysql/include/mysql/usr/include/mysql
Shutdown-r now # restart the system. wait until the system is restarted and continue to perform the following operations on the terminal command line.
Mysql_secure_installation # set the Mysql password
Press Y to enter the password twice as prompted.
Or directly change the password/usr/local/mysql/bin/mysqladmin-u root-p password "mysql" # change the password
Service mysqld restart # restart
Enter current password for root (enter for none) appears when you set a password or connect to MYSQL ):
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql. sock' (2)
You can execute this sentence to solve the problem.
[Root @ localhost data] # rm-rf/tmp/mysql. sock
After MYSQL is started, the mysql. sock file is available under/var/lib/mysql.
[Root @ localhost data] # ln-s/var/lib/mysql. sock/tmp/mysql. sock (use the absolute path)
If an error persists, use
[Root @ localhost/] # mysql-u root-p-S/var/lib/mysql. sock
Skip password verification login
Mysql> update mysql. user set password = password ("mysql") where user = 'root ';
Mysql> flush privileges;
Mysql> quit
That is, you can.
In addition, MYSQL can only be accessed locally by default.
Create a user: testuser and authorize remote access
Connect to mysql as root
Mysql-u root-p
Enter the password and mysql
Create a testuser account
Mysql> create user "testuser" identified by "test123456 ";
Grant testuser permissions
Mysql> GRANTALL PRIVILEGES ON.TO "testuser" @ "%" identified by "testuser password ";
Refresh permission takes effect
Mysql> FLUSHPRIVILEGES;
Mysql> quit
III. Summary
During MYSQL installation, you may encounter this MYSQL. SOCK problem.
In fact, this mysql. sock uses unix domain socket as a carrier of the communication protocol when the mysql host and client are on the same host.
Mysql usually has two connection methods:
(1) TCP/IP
(2) socket
For mysql. sock, the function is that the program is on the same machine as mysqlserver and SOCKET is available when a local connection is initiated.
You can also specify an IP address and use TCP connection instead of local SOCK.
[Root @ localhost mysql] # mysql-h 127.0.0.1-u root-p mysql
You can also log on directly.
Mysql. sock is generated with every mysql server startup. If you restart mysql after changing my. cnf, it will be generated again and the information has been changed. For external connections, you can also change the port connection.
When installing mysql connections in linux, you are often prompted that the mysql. sock file cannot be found. The solution is also simple:
If the newly installed mysql file is not found, search for it and specify the correct location in/etc/my. cnf and set the soft link in the system.
If the mysql. sock file is deleted by mistake, you need to restart the mysql service. if The restart is successful, mysql. sock will be generated under the datadir directory, and then specified.
If the connection fails, you can use the TCP connection mode. in windows, the MPs queue connection mode is also supported.