Categories
macOs MySQL

Install MySQL on Mac

Install MySQL using Homebrew, open the terminal an type in:

$ brew install mysql

Start MySQL server by typing

$ brew services start mysql

Secure the server by typing

$ mysql_secure_installation

When using brew services start mysql the server will re-start at OS reboot, if you run:

$ brew services stop mysql

This will stop MySQL and not re-start after a OS reboot.

You can also avoid this by typing:

$ mysql.server start

This will start MySQL and keep it running until computer shutdown or by typing:

$ mysql.server stop

Connect to server

$ mysql -u root -p

Categories
macOs Qt

macdeployqt – deploying on macOS

The deployment tool can be found at

$ QTDIR/{VERSION}/{COMPILER}/bin/macdeployqt

How to use the macdeployqt tool using the terminal.

OptionDescription
-verbose=<0-3> 0 = no output, 1 = error/warning (default), 2 = normal, 3 = debug
-no-pluginsSkip plugin deployment
-dmgCreate a .dmg disk image
-no-stripDon’t run ‘strip’ on the binaries
-use-debug-libsDeploy with debug versions of frameworks and plugins (implies -no-strip)
-executable=Let the given executable also use the deployed frameworks
-qmldir=Deploy imports used by .qml files in the given path
$ QTDIR/{VERSION}/{COMPILER}/bin/macdeployqt <path to app file generated by build>/appFile.app

Categories
macOs

.bash_profile not working on macOS?

First check if Bash is the default shell:

echo $SHELL

If /bin/bash is not returned, just change it by typing:

chsh -s /bin/bash

Restart your terminal or type in:

source ~/.bash_profile
Categories
Ubuntu

Samba on Ubuntu, using Mac

On Ubuntu

Open the terminal and run:

sudo apt update
sudo apt install samba
sudo nano /etc/samba/smb.conf

At the end of the file, add the following lines:

[sambashare]
   comment = Samba on Ubuntu
   path = /home/username/sambashare
   read only = no
   browsable = yes

Restart samba

sudo service smbd restart

Update firewall rules to allow Samba traffic:

sudo ufw allow samba

Set the samba password for the Ubuntu user

sudo smbpasswd -a username

On Mac:

Open finder and press COMMAND+k, this will open the window “Connect to server”, enter the URL:

smb://server-ip/sambashare
Categories
PostgreSQL Ubuntu

PostgreSQL import database

Postgres login (localhost):

sudo -u postgres psql

Postgres login (external host):

psql -h EXTERNAL_HOST_IP -d DB_NAME -U postgres

Listing databases:

postgres=# \l

Switching databases:

postgres=# \c DB_NAME

Listing tables:

DB_NAME=# \dt

Creating database, user and adding access on PostgreSQL

Create a new database:

postgres=# create database DB_NAME;

Create a new database user:

postgres=# create user USER_NAME with encrypted password 'USER_PASSWORD';

Grant access on database for the user

postgres=# grant all privileges on database DB_NAME to USER_NAME

PostgreSQL import database:

sudo -u POSTGRESQL_USER psql -h HOST_IP  -d DB_NAME < SQL_FILE.sql

Categories
GIT Ubuntu

Update To Git Branch Master

Current working branch:

git branch
* master

Working on a different branch:

git checkout -b ANOTHER_BRANCH
Switched to a new branch 'ANOTHER_BRANCH'

Check if there are some new commits on master:

git checkout master
git pull

Merge changes

The easiest approach for merging the changes would be:

git checkout ANOTHER_BRANCH
git merge master

If there are differences, then merge will apply the commits to the top of ANOTHER_BRANCH and create a new merge commit. Otherwise, the merge will be resolved by a fast-forward.

Rebase

git checkout ANOTHER_BRANCH
git rebase master

Rebase moves all diverging commits of ANOTHER_BRANCH to the top. The diverging commits will have new hashes because history will be rewritten. Accordingly, if you’ve previously pushed your feature branch to remote, then the only way to update it is with force push.