關於Ubuntu18.04 linux系統使用安裝JDK Mysql

平臺部署

 

1、安裝JDK

step1.下載OracleJDK
step2. 解壓
step3. 加入環境變量java

具體操做以下:mysql

lemon@ubuntu:~$ cd ~/download/ lemon@ubuntu:~/download$ wget http://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz lemon@ubuntu:~/download$ tar vxf jdk-8u191-linux-x64.tar.gz lemon@ubuntu:~/download$ ls #查看當前目錄下的文件 jdk1.8.0_191 jdk-8u191-linux-x64.tar.gz lemon@ubuntu:~/download$ sudo mv jdk1.8.0_191/ /usr/local/jdk1.8/ #將jdk1.8.0_191文件夾移動到/usr/local/下並重命名爲jdk1.8 lemon@ubuntu:~/download$ sudo vim /etc/profile #編輯環境變量 

在環境變量末尾加入以下內容:linux

export JAVA_HOME=/usr/local/jdk1.8
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=.:${JAVA_HOME}/bin:$PATH

保存後從新加載環境變量,使生效:web

lemon@ubuntu:~/download$ source /etc/profile #刷新環境變量,使生效 lemon@ubuntu:~$ java -version#輸入java -version,如顯示如下信息,則JDK安裝成功 java version "1.8.0_191" Java(TM) SE Runtime Environment (build 1.8.0_191-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode) 

2、安裝MySQL

step1. 安裝MySQL並配置
step2. 建立數據庫與表sql

因爲在安裝Ubuntu系統時,本人選擇了安裝LAMP服務,因此MySQL已安裝完成,僅需設置便可啓用。數據庫

測試是否安裝:ubuntu

lemon@ubuntu:~$ mysql #輸入mysql,如出現如下提示,說明已安裝mysql ERROR 1045 (28000): Access denied for user 'lemon'@'localhost' (using password: NO) 

如未安裝:vim

lemon@ubuntu:~$ sudo apt-get install mysql-server lemon@ubuntu:~$sudo apt isntall mysql-client lemon@ubuntu:~$sudo apt install libmysqlclient-dev 

如已安裝:ruby

lemon@ubuntu:~$ sudo mysql_secure_installation 

二者都會進入MySQL設置過程,具體設置內容以下:bash

#1 VALIDATE PASSWORD PLUGIN can be used to test passwords... Press y|Y for Yes, any other key for No: N(不啓用弱密碼檢查) #2 Please set the password for root here... New password: (設置root密碼) Re-enter new password: (重複輸入) #3 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... Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y(不啓用匿名用戶) #4 Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network... Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y (不容許root遠程登錄) #5 By default, MySQL comes with a database named 'test' that anyone can access... Remove test database and access to it? (Press y|Y for Yes, any other key for No) : N #6 Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y (馬上刷新權限表) All done! 

接下來進入進入MySQL進行操做:

#最新版的MySQL安裝以後沒法使用密碼進行登錄,須要sudo登陸修改登陸方式 lemon@ubuntu:~$ sudo mysql -uroot -p Enter password: (空密碼) mysql> mysql>UPDATE mysql.user SET authentication_string=PASSWORD('LEMON'), plugin='mysql_native_password' WHERE user='root'; mysql> FLUSH PRIVILEGES; mysql>exit lemon@ubuntu:~$ sudo service mysql restart lemon@ubuntu:~$ mysql -u root -p Enter password: (上一步設置的密碼,PASSWORD括號內的) mysql>CREATE DATABASE nutch; mysql>USE nutch mysql> CREATE TABLE `webpage` ( `id` varchar(767) NOT NULL, `headers` blob, `text` mediumtext DEFAULT NULL, `status` int(11) DEFAULT NULL, `markers` blob, `parseStatus` blob, `modifiedTime` bigint(20) DEFAULT NULL, `score` float DEFAULT NULL, `typ` varchar(32) CHARACTER SET latin1 DEFAULT NULL, `baseUrl` varchar(767) DEFAULT NULL, `content` longblob, `title` varchar(2048) DEFAULT NULL, `reprUrl` varchar(767) DEFAULT NULL, `fetchInterval` int(11) DEFAULT NULL, `prevFetchTime` bigint(20) DEFAULT NULL, `inlinks` mediumblob, `prevSignature` blob, `outlinks` mediumblob, `fetchTime` bigint(20) DEFAULT NULL, `retriesSinceFetch` int(11) DEFAULT NULL, `protocolStatus` blob, `signature` blob, `metadata` blob, `batchId`varchar(767)DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB ROW_FORMAT=COMPRESSED DEFAULT CHARSET=utf8mb4; mysql>exit 

*最新版本默認狀況下,MySQL是不容許遠程登陸的,如需遠程訪問須要作一些修改:

lemon@ubuntu:~$sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf #將bind-address = 127.0.0.1註釋掉,重啓MySQL服務 lemon@ubuntu:~$sudo service mysqld start 

接下來就能夠經過Navicat等軟件,在其餘計算機訪問數據庫了。

 

 
相關文章
相關標籤/搜索