How Do You Get the mysql Command to Work from an Ubuntu Linux Command Line?

Problem scenario
The mysql command does not work from Ubuntu. You try to run a “mysql” command but you get “command not found.” What do you do to install a mysql CLI utility?

Solution
Run one of the following:

sudo apt -y install mysql-client-core-5.7
sudo apt -y install mariadb-client-core-10.1

These commands may help you too:

apt-cache search mysql-client
apt-cache search mariadb-client
sudo apt -y install mycli
sudo mysql -u root

How Do You Configure HeidiSQL to Work with Postgres?

Problem scenario
You have a Windows desktop computer with HeidiSQL installed on it. You have a Linux server with Postgres installed on it.  How do you get your SQL front end (e.g., Hiedi SQL), to work with the Postgres database?

Solution
Part 1 / From the back end:
1.
  Modify this file /etc/postgresql/9.5/main/postgresql.conf so this stanza is not commented out:
listen_addresses = ‘localhost’ 

# Make sure in the quotes there is a space and then the external IP address of the Postgres server.

How Do You Troubleshoot this Error “java.lang.ClassNotFoundException: com.mysql.jdbc.Driver”?

Problem scenario
In Linux you are trying to run a Java program that connects to a MySQL database. The program compiles, but it does not run. You get this error: “java.lang.ClassNotFoundException: com.mysql.jdbc.Driver” What should you do?

Solution

1. Set the CLASSPATH variable in two steps. First set it to where the .class file is for the Java file you are running.

How Do You Troubleshoot This Message “ImportError: No module named ‘google.cloud’?

Problem scenario
You run a Python program or from the Python command prompt you receive this message:

Traceback (most recent call last):
  File “main.py”, line 21, in <module
    from google.cloud import pubsub_v1
 ImportError: No module named ‘google.cloud’

ModuleNotFoundError: No module named ‘google’

What should you do to eliminate this problem?

Possible Solution #1
Try to run the program as sudo:

sudo python nameOfProg.py

Possible Solution #2
Try this with or without sudo (depending on whether or not you are using “sudo” to run the Python program):

sudo pip install google-cloud-bigquery

# You may or may not want to omit the “sudo” in the above command.

How Do You Use docker-compose?

Problem scenario
You want to create an example of a docker compose file.  How do you use docker-compose?

Prerequisites
i.  This assumes you have Docker installed and running.  If you need assistance, see this posting.
ii.  This assumes that you have installed docker-compose.  If you need assistance, see this posting.
iii.  This assumes the Docker host has access to the internet.

How Do You Troubleshoot the Error “ERROR 1273 (HY000): Unknown collation: ‘utf8mb4_general_ci6′”?

Problem scenario
You are trying to follow the Drupal installation instructions.  You run this command from a mysql prompt:

mysql> CREATE DATABASE drupaldb CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci6;

But you get this error: “ERROR 1273 (HY000): Unknown collation: ‘utf8mb4_general_ci6′”

What should you do?

Solution
To find the potential collations that you can run (based on your SQL database), run this command:  

SHOW COLLATION;

How Do You Troubleshoot “postgresql.Driver Connection error: org.postgresql.util.PSQLException Fatal: Ident authentication failed for user”?

Problem scenario
You are trying to connect to a PostgreSQL database.  Your database username and password are not working, but you think they should.  You get the message:  “postgresql.Driver Connection error: org.postgresql.util.PSQLException Fatal: Ident authentication failed for user”

What should you do?

Possible solution #1
Make sure the pg_hba.conf file is configured correctly.

Here is an example if you are trying to connect from your local machine and you do not need your Postgres instance extremely hardened:

# TYPE 

How Do You Troubleshoot the Oracle and Java Message “java.sql.sqlexception ora-01003 no statement parsed”?

Problem scenario
You run a Java program that runs a SQL statement in an Oracle database.  You get this error: “java.sql.sqlexception ora-01003 no statement parsed”.  What do you do to fix this?

Solution
Run the Java program a second time.  Does the problem remain?  It could be that there was a successful DDL command, and this error could be ignorable.  

You may want to try these links for further info:
https://stackoverflow.com/questions/23866710/ora-01003-no-statement-parsed
https://community.oracle.com/thread/736289 (this link used to work)

How Do You Troubleshoot SonarQube Not Working when the Logs Have a Comment about Not Being Able to Connect to the Database?

Problem scenario
In the SonarQube logs you get an error “java.lang.IllegalStateException: Can not connect to database.  Please check connectivity and settings (see the properties prefixed by ‘sonar.jdbc’)”

How do you troubleshoot this error?

Solution
1.  Verify you can ping the hostname.  

2.  Test the port with nmap (e.g., “nmap -p 1521 <databaseFQDN>” where <databaseFQDN> is the hostname of the database and 1521 is the port you configured in the stanza with “sonar.jdbc”).