Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of installing and configuring JDK+TOMCAT+MYSQL under centos6.4

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "how to install and configure JDK+TOMCAT+MYSQL under centos6.4". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

In the company test environment, you need to install and configure JDK+TOMCAT+MYSQL under CENTOS6.4. Here is a reserve of installation notes.

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 to see if the JDK that comes with centos is installed, using the command java-version, 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)

Openjdk1.6 has been installed, this package has limited functions, it is best to uninstall openjdk first, and then install sun 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 JDK from SUN

# chmod axix jdk-6u43-linux-x64-rpm.bin

#. / jdk-6u43-linux-x64-rpm.bin (path defaults to / usr/java)

# java-version

Java version "1.6.043"

Java (TM) SE Runtime Environment (build 1.6.0_43-b01)

Java HotSpot (TM) 64-Bit Server VM (build 20.14-b01, mixed mode)

If it is a BIN package directly, it needs to be set in / ETC/profile to java-version.

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 tomcat

This is the end of the installation. Set the environment variable.

# vi / etc/profile add the following statement

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/tomcat

Export CATALINA_HOME=/usr/tomcat/tomcat

# source / etc/profile (to make the environment variable effective)

Start TOMCAT

# cd bin

#. / startup.sh

Using CATALINA_BASE: / usr/tomcat/tomcat

Using CATALINA_HOME: / usr/tomcat/tomcat

Using CATALINA_TMPDIR: / usr/tomcat/tomcat/temp

Using JRE_HOME: / usr/java/jdk1.6.0_43

Using CLASSPATH: / usr/tomcat/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 generally requires cmake compilation and installation. Here we install the mysql5.5.23 version. Record the installation steps and process of CMAKE here for subsequent reference.

If a missing toolkit is found during compilation and installation, download and install it separately with yum install before continuing.

Several issues that need to be explained in advance in the following installation:

Mysql will be installed in the / usr/local/mysql/ directory

The default installation of mysql uses the utf8 character set

The data and log files of mysql are saved in the corresponding directory of / var/mysql/

The configuration file for mysql is saved in / etc/my.cnf

Configuration and installation

# useradd mysql

# passwd mysql

# groupadd mysql

# useradd-g mysql 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 ncurses-devel gcc-c++ libstdc++

(you can configure a local YUM source or an external mirror source)

# 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 (--without-debug-- all-static)

If an error is encountered during installation

Clear the cache:

Make clean

Rm CMakeCache.txt

And then proceed.

# 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 is suitable for servers with about 1G memory. You can choose different configurations such as my-large.cnf or my-huge.cnf according to your own configuration)

Then vi / etc/my.cnf

Edit the configuration file and add it in the [mysqld] section

Datadir=/var/mysql/data # add MySQL database path

Enter the scripts directory and execute

#. / 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

This generates the mysql system database

Then set up the MYSQL service

Cp. / support-files/mysql.server / etc/init.d/mysqld # add Mysql to the system startup

Chmod adepx / etc/init.d/mysqld # increased execution permissions

Chkconfig-add mysqld

Chkconfig-level 345 mysqld on

Vi / etc/init.d/mysqld # editing

Basedir = / usr/local/mysql # MySQL program installation path (note that the = sign has no spaces)

Datadir = / var/mysql/data # MySQl database storage directory (note that the = sign has no spaces)

[root@localhost data] # service mysqld start

Starting MySQL... SUCCESS!

[root@localhost data] # netstat-an | grep 3306

Tcp 0 0 0.0.0.0 3306 0.0.0.015 * LISTEN

At this point, the 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 library files of myslq to the default location of the system, so that you don't have to specify the library file address of mysql when compiling software like PHP.

Ln-s / usr/local/mysql/lib/mysql / usr/lib/mysql

Ln-s / usr/local/mysql/include/mysql / usr/include/mysql

Shutdown-r now # needs to restart the system and continue to operate under the terminal command line after waiting for the system to restart

Mysql_secure_installation # set the Mysql password

Press enter Y to enter the new password twice according to the prompt

Setting the root password ensures that nobody can log into the MySQL

Root user without the proper authorisation.

Set root password? [Y/n]

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

... Success!

Or change the password directly / 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 setting a password or connecting 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 you start MYSQL, there will be a mysql.sock file under / var/lib/mysql

[root@localhost data] # ln-s / var/lib/mysql/mysql.sock / tmp/mysql.sock (to use absolute path)

If there is still an error, use the

[root@localhost /] # mysql-u root-p-S / var/lib/mysql/mysql.sock

Password authentication login can be skipped

Mysql > update mysql.user set password=password ("mysql") where user='root'

Mysql > flush privileges

Mysql > quit

That's it.

Note: if you don't jump, you can try. Create a directory of / var/lib/mysql, give permissions to mysql users and groups, and then modify my.cnf to change the socket in client and mysqld to / var/lib/mysql/mysql.sock. Then kill the MYSQL process and then execute the sentence with-S, and you can skip password verification.

In addition, MYSQL can only be accessed locally by default. If remote access needs to be set up,

Establish a user: testuser and authorize remote access

Connect to mysql as root

# mysql-u root-p

Prompt for password, enter mysql

Set up a testuser account

Mysql > CREATE USER "testuser" IDENTIFIED BY "test123456"

Authorize testuser permissions

Mysql > grant all privileges on *. * to "testuser" identified by "test123456"

Refresh permission takes effect

Mysql > flush privileges

Mysql > quit

Change the lower_case_table_names=1 in my.cnf (about upper and lowercase characters)

III. Summary

In the process of installing MYSQL, it is easy to encounter this MYSQL.SOCK problem.

In fact, this mysql.sock is that when the host and client of mysql are on the same host, unix domain socket is used as a carrier of communication protocol.

Mysql usually has two ways to connect:

(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 initiating a local connection.

You can also specify an IP address and connect using TCP instead of local SOCK

[root@localhost mysql] # mysql-h 127.0.0.1-u root-p mysql

You can also log in directly.

Mysql.sock is generated with each mysql server startup. If you restart mysql after changing my.cnf, it will be regenerated and the information has been changed. Then for external connections, you can also change the port connection.

When installing a mysql connection under linux, it is often prompted that the mysql.sock file cannot be found, and the solution is simple:

If it is a newly installed mysql and prompts you that the file cannot be found, search for it, specify the correct location in / etc/my.cnf, and make a 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, the mysql.sock will be generated under the datadir directory. You can specify it at that time.

If not, just choose TCP connection, which also supports pipe connection under windows.

This is the end of the content of "how to install and configure JDK+TOMCAT+MYSQL under centos6.4". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report