ubuntu--JAVA开发环境配置

一、JDK1.8安装及配置

下载: jdk-8u181-linux-x64.tar.gz
下载地址:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
下载到:/home/sharps/下载/jdk-8u181-linux-x64.tar.gz

-----切换root
sharps@sharps-computer:~$ sudo su
-----创建java目录
root@sharps-computer:/home/sharps# mkdir /opt/java
-----拷贝到安装目录
root@sharps-computer:/home/sharps# cp /home/sharps/下载/jdk-8u181-linux-x64.tar.gz /opt/java
解压到 /opt/java
root@sharps-computer:/home/sharps# sudo tar -zxvf /opt/java/jdk-8u181-linux-x64.tar.gz -C
-----配置全局用户环境变量,添加在文档开始
root@sharps-computer:/home/sharps# gedit /etc/profile

	export JAVA_HOME=/opt/java/jdk1.8.0_181 
	export JRE_HOME=${JAVA_HOME}/jre  
	export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib  
	export PATH=${JAVA_HOME}/bin:$PATH

-----环境变量设置生效
root@sharps-computer:/home/sharps# source /etc/profile
-----查看环境变量
root@sharps-computer:/home/sharps# export

declare -x CLASSPATH=".:/opt/java/jdk1.8.0_181/lib:/opt/java/jdk1.8.0_181/jre/lib:/opt/apache-maven-3.5.4/lib"
declare -x COLORTERM="truecolor"
declare -x DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/0/bus"
declare -x DISPLAY=":0"
declare -x HOME="/root"
declare -x JAVA_HOME="/opt/java/jdk1.8.0_181"
declare -x JRE_HOME="/opt/java/jdk1.8.0_181/jre"
declare -x PATH="/opt/java/jdk1.8.0_181/bin:/opt/java/jdk1.8.0_181/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"

root@sharps-computer:/home/sharps# java -version

java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

-----重启后发现 其他用户环境变量设置有效,root 无效
-----设置root 环境变量
root@sharps-computer:~# gedit .bashrc

export JAVA_HOME=/opt/java/jdk1.8.0_181 
export JRE_HOME=${JAVA_HOME}/jre  
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib  
export PATH=${JAVA_HOME}/bin:$PATH

二、 MySQL安装及配置

1.MySQL安装

------mysql 在代理环境下安装
root@sharps-computer:~# sudo apt-get -o Acquire::http::proxy=“http://proxy3.bj.petrochina:8080/” update
root@sharps-computer:~#sudo apt-get install -o Acquire::http::proxy=“http://proxy3.bj.petrochina:8080/” mysql-server
------mysql 非代理环境下安装
root@sharps-computer:~#sudo apt-get update
root@sharps-computer:~#sudo apt-get install mysql-server

2.MySQL配置

----运行安全脚本。
root@sharps-computer:~#sudo mysql_secure_installation
这将提示您输入您在步骤1中创建的 root 密码。您可以按 Y,设置密码,然后 ENTER 接受所有后续问题的默认值。

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1        
Please set the password for root here.

New password: 

Re-enter new password: 

Estimated strength of the password: 50 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
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? (Press y|Y for Yes, any other key for No) : 

 ... skipping.

3.MySQL测试
按上边方式安装完成后,MySQL应该已经开始自动运行了。要测试它,请检查其状态。

root@sharps-computer:~#systemctl status mysql.service
------您将看到类似于以下内容的输出:

● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: en
   Active: active (running) since Thu 2018-09-20 14:16:06 CST; 19min ago
 Main PID: 12945 (mysqld)
    Tasks: 29 (limit: 4915)
   CGroup: /system.slice/mysql.service
           └─12945 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pi

920 14:16:06 sharps-computer systemd[1]: Starting MySQL Community Server...
920 14:16:06 sharps-computer systemd[1]: Started MySQL Community Server.

-----如果MySQL没有运行,您可以启动它:
root@sharps-computer:~#sudo systemctl mysql start

-----如果额外的检查,您可以尝试使用该 mysqladmin 工具连接到数据库,该工具是允许您运行管理命令的客户端。例如,该命令表示以 root(-u root)方式连接到 MySQL ,提示输入密码(-p)并返回版本。
root@sharps-computer:~#mysqladmin -p -u root version
------你应该看到类似的输出:

mysqladmin  Ver 8.42 Distrib 5.7.23, for Linux on x86_64
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Server version		5.7.23-0ubuntu0.18.04.1
Protocol version	10
Connection		Localhost via UNIX socket
UNIX socket		/var/run/mysqld/mysqld.sock
Uptime:			40 min 52 sec

Threads: 1  Questions: 11  Slow queries: 0  Opens: 107  Flush tables: 1  Open tables: 100  Queries per second avg: 0.004

这意味着MySQL正在运行。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值