Technical Documentation Site

Version 0.9.0

Technical Cheat Sheets

MySql


MySql installation on Mac:

If you have previously installed mysql, remove it. (I had mysql-5.7.20-macos10.12-x86_64)
https://community.jaspersoft.com/wiki/uninstall-mysql-mac-os-x

Download mysql: mysql-5.7.21-1-macos10.13-x86_64.dmg

Double click on the downloaded dmg package to install it.

https://dev.mysql.com/doc/refman/5.7/en/osx-installation-pkg.html

At the end of the install you will see a window with the temp root password.

Create a symbolic link to your mysql installation:

ln -s /usr/local/mysql /usr/local/mysql-5.7.20-macos10.12-x86_64

Add /usr/local/mysql/bin to your PATH in ~/.bash_profile

source ~/.bash_profile

Verify the path with

echo $PATH

Start mysql from settings->mysql

If you cannot start mysql from the mysql UI in mac, try this way

cd /usr/local/mysql/support-files

./mysql.server start

Check whether mysql is running:

ps aux | grep mysql

Stop mysql server:

./mysql.server stop

Enter mysql console:

mysql -u root -p  

(Type the temporary password displayed during mysql package installation)

Change the temp root password:

SET PASSWORD = PASSWORD('new root password');

Create user test_user and grant all privileges. Allows test_user to connect to mysql server from any remote host

create user 'test_user'@'%' identified by '<password for test_user>;   
grant all privileges on *.* to 'test_user'@'%';  `  
flush privileges;`  

Commands
Load data from a sql file
mysql -u user_name -p database_name < dump.sql

Enter password when prompted

Last updated on 6 May 2020
Published on 6 May 2020
Edit on GitHub