How to install JDK and Mysql on Ubuntu 18.04 Linux system

How to install JDK and Mysql on Ubuntu 18.04 Linux system

Platform deployment

1. Install JDK

step1. Download OracleJDK
Step 2. Unzip
step3. Add environment variables

The specific operations are as follows:

lemon@ubuntu:~$ cd ~/download/
lemon@ubuntu:~/download$ wget https://download.oracle.com/otn-pub/java/jdk/13.0.2+8/d4173c853231432d94f001e99d882ca7/jdk-13.0.2_linux-x64_bin.tar.gz

lemon@ubuntu:~/download$ tar vxf jdk-8u191-linux-x64.tar.gz
lemon@ubuntu:~/download$ ls #View the files in the current directory
jdk1.8.0_191 jdk-8u191-linux-x64.tar.gz
lemon@ubuntu:~/download$ sudo mv jdk1.8.0_191/ /usr/local/jdk1.8/ #Move the jdk1.8.0_191 folder to /usr/local/ and rename it to jdk1.8
lemon@ubuntu:~/download$ sudo vim /etc/profile #Edit environment variables

Add the following to the end of the environment variables:

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

After saving, reload the environment variables to make them take effect:

lemon@ubuntu:~/download$ source /etc/profile #Refresh environment variables to take effect
lemon@ubuntu:~$ java -version#Enter java -version. If the following information is displayed, the JDK is successfully installed.
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. Install MySQL

Step 1. Install MySQL and configure
step2. Create database and table

Since I chose to install the LAMP service when installing the Ubuntu system, MySQL has been installed and only needs to be set up to enable it.

Test whether it is installed:

lemon@ubuntu:~$ mysql #Enter mysql. If the following prompt appears, it means that mysql has been installed.
ERROR 1045 (28000): Access denied for user 'lemon'@'localhost' (using password: NO)

If not installed:

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

If already installed:

lemon@ubuntu:~$ sudo mysql_secure_installation

Both will enter the MySQL setup process, the specific settings are as follows:

#1
VALIDATE PASSWORD PLUGIN can be used to test passwords...
Press y|Y for Yes, any other key for No: N (disable weak password check)

#2
Please set the password for root here...
New password: (set root password)
Re-enter new password: (re-enter)

#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 (Do not enable anonymous users)

#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 (Do not allow root remote login)

#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 (Refresh privilege tables immediately)

All done!

Next, enter MySQL to operate:

#After installing the latest version of MySQL, you cannot log in using a password. You need to log in with sudo to modify the login method.
lemon@ubuntu:~$ sudo mysql -uroot -p
Enter password: (blank 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: (the password set in the previous step, in the PASSWORD brackets)
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

*By default, MySQL does not allow remote login. If you need remote access, you need to make some modifications:

lemon@ubuntu:~$sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
#Comment out bind-address = 127.0.0.1 and restart the MySQL service
lemon@ubuntu:~$ sudo service mysqld start

Next, you can access the database on other computers through software such as Navicat.

That's it.

You may also be interested in:
  • Complete tutorial on installing Apache, MySQL, PHP, LAMP on Ubuntu 18.04
  • Ubuntu 18.04 does not prompt for password when installing MySQL and how to solve it
  • Detailed explanation of the process of installing MySQL on Ubuntu 18.04.4

<<:  MySql quick insert tens of millions of large data examples

>>:  Node.js+postman to simulate HTTP server and client interaction

Recommend

CentOS7.x uninstall and install MySQL5.7 operation process and encoding format modification method

1. Uninstalling MySQL 5.7 1.1查看yum是否安裝過mysql cd y...

Syntax alias problem based on delete in mysql

Table of contents MySQL delete syntax alias probl...

Axios secondary encapsulation example Demo in the project

1. Why do packaging? Facilitates overall code cal...

Element Plus implements Affix

Table of contents 1. Component Introduction 2. So...

HTML mouse css control

Generally speaking, the mouse is displayed as an u...

Some suggestions for improving Nginx performance

If your web application runs on only one machine,...

HTML tag overflow processing application

Use CSS to modify scroll bars 1. Overflow setting...

Detailed explanation of Linux system directories sys, tmp, usr, var!

The growth path from a Linux novice to a Linux ma...

Use image to submit the form instead of using button to submit the form

Copy code The code is as follows: <form method...

HTML line spacing setting methods and problems

To set the line spacing of <p></p>, us...

A brief discussion on CSS3 animation jamming solutions

Why is it stuck? There is a premise that must be ...

Ubuntu 15.04 opens mysql remote port 3306

Ubuntu 15.04 opens MySQL remote port 3306. All th...