SQL within 1and1 databases – basic commands

Access the database within 1and1 using Putty and SSH – this is the easy part, and I’m into SQL Monitor where the prompt is: mysql>

Note: 1and1 is using Oracle, which is convenient for learning and I can create a bunch of different databases.

Q: How to know the names of the tables within the database?
A: show tables from ;
A: Below:
mysql> show tables from db610639204;

| Tables_in_db610639204 |
| accessprofile |
| accessright |
| accessscope |
| action |
| activity |
| activityprice |
| affectation |
| alert |
| approver |
| assignment |
| attachment |
| audit |
| auditsummary |
| bill |
| billline |
| calendar |
| calendardefinition |
| checklist |
| checklistable |
| checklistdefinition |
| checklistdefinitionline |
| checklistline |
| client |
| collapsed |
| columnselector |
| command |
| context |
| contexttype |
| copyable |
| criticality |
| decision |
| delay |
| delayunit |
| deliverymode |
| dependable |
| dependency |
| document |
| documentdirectory |
| documentversion |
| efficiency |
| event |
| expense |
| expensedetail |
| expensedetailtype |
| favorite |
| favoriteparameter |
| feasibility |
| filter |
| filtercriteria |
| habilitation |
| habilitationother |
| habilitationreport |
| health |
| history |
| importable |
| importlog |
| indicator |
| indicatorable |
| indicatorableindicator |
| indicatordefinition |
| indicatorvalue |
| issue |
| likelihood |
| link |
| linkable |
| list |
| mail |
| mailable |
| measureunit |
| meeting |
| menu |
| menuselector |
| message |
| milestone |
| mutex |
| note |
| opportunity |
| origin |
| originable |
| otherversion |
| overallprogress |
| parameter |
| payment |
| paymentdelay |
| paymentmode |
| periodicity |
| periodicmeeting |
| plannedwork |
| planningelement |
| planningmode |
| plugin |
| predefinedtext |
| priority |
| privacy |
| product |
| profile |
| project |
| projecthistory |
| quality |
| question |
| quotation |
| recipient |
| referencable |
| report |
| reportcategory |
| reportparameter |
| requirement |
| resource |
| resourcecost |
| risk |
| risklevel |
| role |
| runstatus |
| severity |
| sla |
| status |
| statusmail |
| team |
| tempupdate |
| term |
| testcase |
| testcaserun |
| testsession |
| textable |
| ticket |
| today |
| todayparameter |
| trend |
| type |
| urgency |
| version |
| versionproject |
| visibilityscope |
| work |
| workelement |
| workflow |
| workflowstatus |
| workperiod |
138 rows in set (0.15 sec)

Note: This is the Projeqtor database, which is quite commprehensive

Q: How to know the fields within a table? In this case, the table is called “Client”
A: show columns from client;
A: This comes back with information within each of these colunns, at the field level:
Field | Type | Null | Key | Default | Extra

Installing Oracle Database 11g Express Edition

Desired Outcome:

Installation of Oracle’s Database, which maybe premature considering I’ve just installed MariaDB. Hopefully, I can have both systems running at the same time. Strategically good to learn Oracle first.

This is the main web-site for information and downloads:

This is the main site for documentation:

This is the readme info for documentation:
Note: Nothing much of importance

This is the Installation Guide for Linux:

MariaDB – Admin – Primer1 – Intro

This is the index for the Primer
XREF to: https://mariadb.com/kb/en/mariadb/a-mariadb-primer-01-intro/

Basic overview of this intro-level primer into access the mysql prompts and modifying a database

Note: I have everything they’re needing for the primer — functioning MariaDB system

When I run (logged in as root): mysql -u root -p
This happens: Access denied for user ‘root’@’localhost’ (using password: YES)
Note: I don’t get why I now cannot load the MariaDB console
Answer: When I was entering the password, I was entering the root password and not for the MariaDB

MariaDB [(none)]>
Note: This tell me that the MariaDB monitor is running without a database loaded

Various commands to learn in MariaDB:

MariaDB – Admin – Troubleshooting server start issues

XREF to: https://mariadb.com/kb/en/mariadb/what-to-do-if-mariadb-doesnt-start/

Q: How to track events by looking at the logs? Where are they stored?
A: Named “host-name.err” and written to the data directory
Note: In my case, I didn’t see specific files like that, but did see useful files to review
-yum.log; messages-20151120, etc

Q: How do you search for the error logs, if they’re not where you think they would be?
A: mysqld –help –verbose | grep ‘datadir’ | tail -1 (Note: In my case a plug-in wasn’t working)

Q: What is the my.cnf file?
A: Contains configuration settings, ie where data directory is

Note: Important at some point to figure out how to configure my.cnf to set up the basedir, etc

MariaDB – Admin – mysqladmin

mysqladmin is used to run commands against mysqld daemon

XREF to this doc for info: http://www.ewhathow.com/2013/09/how-to-check-if-mysql-server-is-running-on-linux/
XREF to this MariaDB doc: https://mariadb.com/kb/en/mariadb/mysqladmin/

Q: How to check if MySQL Process is running?
A: ps aux | grep mysql
mysql 9555 0.0 7.2 774240 133436 ? Ssl 14:17 0:02 /usr/sbin/mysq d
paul 9713 0.0 0.2 162420 4212 pts/0 T 15:02 0:00 mysql -u root -p
root 9812 0.0 0.0 112640 964 pts/0 S+ 15:29 0:00 grep –color=auto mysql
Note: ERROR! MySQL is running but PID file could not be found

Q: Logged in as root, is mysqladmin running?
A: mysqladmin status
Note: mysqladmin: connect to server at ‘localhost’ failed
error: ‘Access denied for user ‘root’@’localhost’ (using password: NO)’
Note: Issue is that syntax requires authentication

Q: How to check mysqladmin running?
A: mysqladmin -u root -p status (Note: Enter password I have for database system)
Uptime: 4748 Threads: 2 Questions: 27 Slow queries: 0 Opens: 0 Flush tables: 1 Open tables: 11 Queries per second avg: 0.005

Q: As an experiment, stop the SQL service, check for mysqladmin running, start the service again
A: sudo systemctl stop mariadb.service
A: mysqladmin -u root -p status
Note: mysqladmin: connect to server at ‘localhost’ failed
error: ‘Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2 “No such file or directory”)’
Check that mysqld is running and that the socket: ‘/var/lib/mysql/mysql.sock’ exists!
A: sudo systemctl start mariadb.service
A: mysqladmin -u root -p status
Note: Uptime: 7 Threads: 1 Questions: 1 Slow queries: 0 Opens: 0 Flush tables: 1 Open tables: 11 Queries per second avg: 0.142
Summary: Output of “mysqladmin status” will give a definite answer on whether the MySQL service is running.

Q: How to check status of mysql service (because I’m using CentOS)
A: service mysql status
Note: ERROR! MySQL is running but PID file could not be found
Note: Instructions within here to fix this: http://geeksterminal.com/fix-mysql-is-running-but-pid-file-could-not-be-found-error/342/

Q: What is the PID file that it was referring to?

Q: What happens when I enter: mysqladmin -u root -p (and enter the database system password)?
mysqladmin Ver 9.1 Distrib 10.1.8-MariaDB, for Linux on x86_64
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Administration program for the mysqld daemon.
Usage: mysqladmin [OPTIONS] command command….

Default options are read from the following files in the given order:
/etc/my.cnf ~/.my.cnf
The following groups are read: mysqladmin client client-server client-mariadb
The following options may be given as the first argument:
–print-defaults Print the program argument list and exit.
–no-defaults Don’t read default options from any option file.
–defaults-file=# Only read default options from the given file #.
–defaults-extra-file=# Read this file after the global files are read.

-c, –count=# Number of iterations to make. This works with -i
(–sleep) only.
–debug-check Check memory and open file usage at exit.
–debug-info Print some debug info at exit.
-f, –force Don’t ask for confirmation on drop database; with
multiple commands, continue even if an error occurs.
-C, –compress Use compression in server/client protocol.
Directory for character set files.
Set the default character set.
-?, –help Display this help and exit.
-h, –host=name Connect to host.
-b, –no-beep Turn off beep on error.
-p, –password[=name]
Password to use when connecting to server. If password is
not given it’s asked from the tty.
-P, –port=# Port number to use for connection or 0 for default to, in
order of preference, my.cnf, $MYSQL_TCP_PORT,
/etc/services, built-in default (3306).
–protocol=name The protocol to use for connection (tcp, socket, pipe,
-r, –relative Show difference between current and previous values when
used with -i. Currently only works with extended-status.
-s, –silent Silently exit if one can’t connect to server.
-S, –socket=name The socket file to use for connection.
-i, –sleep=# Execute commands repeatedly with a sleep between.
–ssl Enable SSL for connection (automatically enabled with
other flags).
–ssl-ca=name CA file in PEM format (check OpenSSL docs, implies
–ssl-capath=name CA directory (check OpenSSL docs, implies –ssl).
–ssl-cert=name X509 cert in PEM format (implies –ssl).
–ssl-cipher=name SSL cipher to use (implies –ssl).
–ssl-key=name X509 key in PEM format (implies –ssl).
–ssl-crl=name Certificate revocation list (implies –ssl).
–ssl-crlpath=name Certificate revocation list path (implies –ssl).
Verify server’s “Common Name” in its cert against
hostname used when connecting. This option is disabled by
-u, –user=name User for login if not current user.
-v, –verbose Write more information.
-V, –version Output version information and exit.
-E, –vertical Print output vertically. Is similar to –relative, but
prints output vertically.
-w, –wait[=#] Wait and retry if connection is down.
–plugin-dir=name Directory for client-side plugins.
–default-auth=name Default authentication client-side plugin to use.

Variables (–variable-name=value)
and boolean options {FALSE|TRUE} Value (after reading options)
——————————— —————————————-
count 0
debug-check FALSE
debug-info FALSE
force FALSE
compress FALSE
character-sets-dir (No default value)
default-character-set auto
host (No default value)
no-beep FALSE
port 0
relative FALSE
socket (No default value)
sleep 0
ssl-ca (No default value)
ssl-capath (No default value)
ssl-cert (No default value)
ssl-cipher (No default value)
ssl-key (No default value)
ssl-crl (No default value)
ssl-crlpath (No default value)
ssl-verify-server-cert FALSE
user root
verbose FALSE
vertical FALSE
connect-timeout 43200
shutdown-timeout 3600
plugin-dir (No default value)
default-auth (No default value)

Where command is a one or more of: (Commands may be shortened)
create databasename Create a new database
debug Instruct server to write debug information to log
drop databasename Delete a database and all its tables
extended-status Gives an extended status message from the server
flush-all-statistics Flush all statistics tables
flush-all-status Flush status and statistics
flush-client-statistics Flush client statistics
flush-hosts Flush all cached hosts
flush-index-statistics Flush index statistics
flush-logs Flush all logs
flush-privileges Reload grant tables (same as reload)
flush-slow-log Flush slow query log
flush-status Clear status variables
flush-table-statistics Clear table statistics
flush-tables Flush all tables
flush-threads Flush the thread cache
flush-user-statistics Flush user statistics
kill id,id,… Kill mysql threads
password [new-password] Change old password to new-password in current format
old-password [new-password] Change old password to new-password in old format
ping Check if mysqld is alive
processlist Show list of active threads in server
reload Reload grant tables
refresh Flush all tables and close and open logfiles
shutdown Take server down
status Gives a short status message from the server
start-slave Start slave
stop-slave Stop slave
variables Prints variables available
version Get version info from server

Q: Why do I have to enter the password each time I run a mysqladmin command?
A: Because that’s the way it is
Note: mysqladmin -u root -p ping — responds with “mysqld is alive”, but I have to enter password each time

Q: What are some mysqladmin commands I can play with?
A: http://www.tecmint.com/mysqladmin-commands-for-database-administration-in-linux/

Q: How to change the password for root?
A: mysqladmin -u root -p123456 password ‘xyz123’
Note: p123456 was old password and xyz123 is new

Q: How to check if MariaDB/MySQL is running?
A: mysqladmin -u root -p ping
Note: Comes back with, “mysqld is alive”

Q: How to check which version of MariaDB is running?
A: mysqladmin -u root -p version
mysqladmin Ver 9.1 Distrib 10.1.8-MariaDB, for Linux on x86_64
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Server version 10.1.8-MariaDB
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/lib/mysql/mysql.sock
Uptime: 16 hours 46 min 1 sec
Threads: 1 Questions: 8 Slow queries: 0 Opens: 0 Flush tables: 1 Open tables: 11 Queries per second avg: 0.000

Q: How to check status of server, so see threads?
A: mysqladmin -u root -p status
Uptime: 60501 Threads: 1 Questions: 9 Slow queries: 0 Opens: 0 Flush tables: 1 Open tables: 11 Queries per second avg: 0.000

Q: How to check all the running processes?
A: mysqladmin -u root -p processlist
| Id | User | Host | db | Command | Time | State | Info | Progress |
| 19 | root | localhost | | Query | 0 | init | show processlist | 0.000 |

Q: How to create a database?
A: mysqladmin -u root -p create databasename

Q: How to show databases
A: First, go into MariaDB Monitor with – mysql -u root -p
A: show databases;
— +——————–+
| Database |
| information_schema |
| mysql |
| performance_schema |
| test |
4 rows in set (0.00 sec)

Q: How to Drop (AKA Delete, including all tables) a database? This should be done with caution as the data is destroyed.
A: mysqladmin -u root -p drop databasename

Q: How to shutdown MariaDB safely?
A: mysqladmin -u root -p shutdown

Q: Another way of how to shutdown MariaDB?
A: sudo systemctl stop mariadb.service

Q: How to start a server?
A: sudo systemctl start mariadb.service

Q: How to kill a sleeping process?
A: First, find the current processes with — mysqladmin -u root -p processlist
A: mysqladmin -u root -p kill 5,10
Note: The Process ID’s are 5 and 10 — if multiple processes you separate with a comma

Q: How to run multiple commands at same time?
A: mysqladmin -u root -p status version ping
Note: Put a space between each command

Compilation of interests, thoughts and musings…