Linux Commands for Java & MySQL Setup

1. Java Install

First, update the package index.

Next, install Java. Specifically, this command will install the Java Runtime Environment (JRE).

The JDK does contain the JRE, so there are no disadvantages if you install the JDK instead of the JRE, except for the larger file size.

You can install the JDK with the following command:

2. Install MySQL

Step 1 — Installing MySQL Base

On Ubuntu 16.04, only the latest version of MySQL is included in the APT package repository by default. At the time of writing, that's MySQL 5.7

To install it, simply update the package index on your server and install the default package with apt-get.

Step 2 —Run the security script and Configure.

Step 3 — Testing MySQL

Regardless of how you installed it, MySQL should have started running automatically. To test this, check its status.

3. Extract tar/zip

Type man tar for more information, but this command should do the trick:

tar -xvzf community_images.tar.gz

To explain a little further, tar collected all the files into one package, community_images.tar. The gzip program applied compression, hence the gz extension. So the command does a couple things:

4. Folder Permission 

In that chmod -R 755 will set these permissions to all files and subfolders in the tree 

To change all the directories to 755 (drwxr-xr-x):

find /opt/lampp/htdocs -type d -exec chmod 755 {} \;

To change all the files to 644 (-rw-r--r--):

find /opt/lampp/htdocs -type f -exec chmod 644 {} \;

5. Change User in Linux

How about using the su command?

$ whoami

user1

$ su - user2

Password:

$ whoami

user2

$ exit

logout

If you want to log in as root, there's no need to specify username:

$ whoami

user1

$ su -

Password:

$ whoami

root

$ exit

logout

6. MySQL Login

mysql -u USERNAME -pPASSWORD -h HOSTNAMEORIP DATABASENAME 

mysql -u root -p

The options above means:

-u: username

-p: password (**no space between -p and the password text**)

-h: host

last one is name of the database that you wanted to connect. 

7. Reinstall MySQL

Find and remove All Files my.cnf

sudo find / -name my.cnf

Try running the following command to reset and purge all MySQL related things:

sudo apt purge mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server-5.7 mysql-server-core-5.7 mysql-server

Once this is done, run the below to update your system and "clean up" your package cache.

sudo apt update && sudo apt dist-upgrade && sudo apt autoremove && sudo apt -f install

Then, try re-installing MySQL Server:

sudo apt install mysql-server

8. MySQL/MariaDB Status

Secure Installation Permission

sudo chmod -R 755 /var/lib/mysql/

Start

systemctl start mariadb.service

Enable

systemctl enable mariadb.service

Status

service mysqld status

10. CHAR CODE SET - utf8mb4

ALTER DATABASE at CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;

ALTER TABLE CORE_DATA CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Create Table:

CREATE TABLE `CORE_DATA` (

  `id` int(11) NOT NULL AUTO_INCREMENT,

  `type` int(11) DEFAULT NULL,

  `subtype` int(11) DEFAULT NULL,

  `parentID` int(11) DEFAULT NULL,

  `name` varchar(500) DEFAULT NULL,

  `message` varchar(8000) DEFAULT NULL,

  `tags` varchar(500) DEFAULT NULL,

  `orderNo` int(11) DEFAULT NULL,

  `url` varchar(500) DEFAULT NULL,

  `downloadurl` varchar(5000) DEFAULT NULL,

  `blobkey` varchar(500) DEFAULT NULL,

  `blobSize` bigint(20) DEFAULT NULL,

  `actualDate` date DEFAULT NULL,

  `createdDate` date NOT NULL,

  `updatedDate` date DEFAULT NULL,

  `referenceID` int(11) DEFAULT NULL,

  PRIMARY KEY (`id`)

) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4;

SELECT * FROM at.core_data;