• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Search

connect

GCP CloudShell via Terminal

June 20, 2022

Connect to your CloudShell environment from your terminal.

$ gcloud cloud-shell ssh
Welcome to Cloud Shell! Type "help" to get started.
first.last@cloudshell $
first.last@cloudshell $

$ gcloud cloud-shell ssh Welcome to Cloud Shell! Type "help" to get started. first.last@cloudshell $ first.last@cloudshell $

Once logged in, you can set your project.

first.last@cloudshell $ gcloud config set project $PROJECT_ID

first.last@cloudshell $ gcloud config set project $PROJECT_ID

Filed Under: Cloud Tagged With: cloud shell, connect, gcp, terminal

MySQL SSL Connection

April 27, 2020

The standard way to connect to MySQL is:

mysql -h hostname -u user -p

mysql -h hostname -u user -p

Here’s how to connect to MySQL with SSL encryption.

mysql -h hostname -u user -p \
--ssl-ca=server-ca.pem \
--ssl-cert=client-cert.pem \
--ssl-key=client-key.pem

mysql -h hostname -u user -p \ --ssl-ca=server-ca.pem \ --ssl-cert=client-cert.pem \ --ssl-key=client-key.pem

Generate the SSL keys from the MySQL server. Download it to the client.

Filed Under: Linux Tagged With: connect, mysql, secure, ssl

Quick Database Check

March 17, 2017

Here’s a quick PHP script to check if your web server can connect to your MySQL database. It’s a neat little script if you don’t have any application installed yet, and you just want to see if your web server setup can quickly connect to the database. All you have to do is create a new file called connect.php, and place the following code inside. Just change the username, password and database. Most likely the hostname will be localhost.

$ sudo nano /var/www/html/connect.php
$username = "user";
$password = "password";
$hostname = "hostname";
$database = "database";
 
$dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL");
echo "Successfully Connected to the MySQL Database.<br/>";
 
$selected = mysql_select_db("$dbname", $dbhandle) or die("Could not select database");
echo "Successfully Connected to Database called: $database";

$ sudo nano /var/www/html/connect.php $username = "user"; $password = "password"; $hostname = "hostname"; $database = "database"; $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); echo "Successfully Connected to the MySQL Database.<br/>"; $selected = mysql_select_db("$dbname", $dbhandle) or die("Could not select database"); echo "Successfully Connected to Database called: $database";

It’s also available on my Github gist.

Filed Under: PHP Tagged With: connect, mysql

  • Home
  • About
  • Search

Copyright © 2023