2024年9月21日 星期六

How to create the Joplin server with the docker?

1. Get the docker sample configuration file. 

$wget https://raw.githubusercontent.com/laurent22/joplin/dev/.env-sample
$move .env-sample .env
$vim .env

2. The example configuration will like below: 

#=============================================================================
# PRODUCTION CONFIG EXAMPLE
# -----------------------------------------------------------------------------
# By default it will use SQLite, but that's mostly to test and evaluate the
# server. So you'll want to specify db connection settings to use Postgres.
#=============================================================================
#
# APP_BASE_URL=https://example.com/joplin
# APP_PORT=22300
# 
# DB_CLIENT=pg
# POSTGRES_PASSWORD=joplin
# POSTGRES_DATABASE=joplin
# POSTGRES_USER=joplin
# POSTGRES_PORT=5432
# POSTGRES_HOST=localhost
#============================================================================= 
# DEV CONFIG EXAMPLE
# -----------------------------------------------------------------------------
# Example of local config, for development. In dev mode, you would usually use
# SQLite so database settings are not needed.
#=============================================================================
#
# APP_BASE_URL=http://localhost:22300
# APP_PORT=22300

3. If normal usage, use PRODUCTION section. 

PS:If only for debug or demo, use DEV section. 

APP_BASE_URL=https://example.com/joplin 
APP_PORT=22300
DB_CLIENT=pg
POSTGRES_PASSWORD=joplin
POSTGRES_DATABASE=joplin
POSTGRES_USER=joplin
POSTGRES_PORT=5432
POSTGRES_HOST=localhost

PS. Please change the POSTGRES_PASSWORD with you want. 

4. But, even use the docker, this docker will connect to your localhost DB. So, you must manually create the DB on your localhost. 

$sudo -u postgres psql

When you entry into the PostgreSQL console, please type the below command: 

PS. The PASSWORD must equal the POSTGRES_PASSWORD. 

CREATE DATABASE joplin;
CREATE USER joplin WITH PASSWORD 'yourpassword';
ALTER ROLE joplin SET client_encoding TO 'utf8';
ALTER ROLE joplin SET default_transaction_isolation TO 'read committed';
ALTER ROLE joplin SET timezone TO 'UTC';
GRANT ALL PRIVILEGES ON DATABASE joplin TO joplin;
\q

5. Run the docker.

$docker run --net=host --add-host=host.docker.internal:127.0.0.1 --env-file .env -p 22300:22300 joplin/server:latest

6. You can visit the local host on browser. 

http://localhost:22300/ 

7. The default login setting: 

Default username: admin@localhost 

Default password: admin 

8. You can create the bash file to easily run the docker: 

#!/bin/bash
docker pull joplin/server:latest
docker stop joplin
docker rm joplin
docker run -d --restart unless-stopped --name joplin \
			  --net=host \
              --add-host=host.docker.internal:127.0.0.1 \
              --env-file .env \
              -p 22300:22300 \
              joplin/server:latest

9. Reference: 

(1) https://hub.docker.com/r/joplin/server 

(2) https://netivism.com.tw/blog/512 

(3) https://raw.githubusercontent.com/laurent22/joplin/dev/.env-sample

2023年8月1日 星期二

How to build the QT static version on the Windows platform?

1. Download the QT source code from the QT office website.

Download link: https://download.qt.io/archive/qt/5.15/5.15.2/single/qt-everywhere-src-5.15.2.tar.xz
NOTE: This example will use the version QT 5.15.2.

2. Unzip the source code to the local disk.

Example: "D:\qt-everywhere-src-5.15.2"

3. Install the depend tools and library.

The QT was depend some tools or library. By the QT 5.15.2, it was depend below list: 

Perl version 5.12 or later [http://www.activestate.com/activeperl/]

Python version 2.7 or later [http://www.activestate.com/activepython/]

Ruby version 1.9.3 or later [http://rubyinstaller.org/]

4. Open the VS2019 console.

NOTE: This example must need the VS2019 to build the QT source code. Please make sure your PC has installed the VS2019.

Launch the VS2016 console tool: "x64 Native Tools Command Prompt for VS 2019"

It will show some message like below:

 

 

 

5. Change the work folder to "D:\qt-everywhere-src-5.15.2".


$cd D:\qt-everywhere-src-5.15.2

6. Modify the source code: "qtbase\mkspecs\common\msvc-desktop.conf"

QMAKE_CFLAGS_RELEASE = $$QMAKE_CFLAGS_OPTIMIZE -MD

QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_OPTIMIZE -Zi -MD

QMAKE_CFLAGS_DEBUG = -Zi -MDd

to

QMAKE_CFLAGS_RELEASE = $$QMAKE_CFLAGS_OPTIMIZE -MT

QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_OPTIMIZE -Zi -MT

QMAKE_CFLAGS_DEBUG = -Zi -MTd

7. Use the configuration tool to initialize QT code base.


$configure.bat -static -prefix "D:\Qt_static" -confirm-license -opensource -debug-and-release -platform win32-msvc -nomake examples -nomake tests  -plugin-sql-sqlite -plugin-sql-odbc -qt-zlib -qt-libpng -qt-libjpeg -qt-freetype -qt-pcre -qt-harfbuzz -opengl desktop -mp

NOTE: This example will set the final install path is "D:\Qt_static".

8. Download the build tool: "jom".

Download link: http://download.qt.io/official_releases/jom/jom.zip

This tool supports the multiple-core to build the source code on Windows Platform.

We assume your JOM unzip path is "D:/jom_1_1_3/jom.exe".

9. Build the QT source code.

NOTE: Please remember to change the work folder to the QT source code folder, like the "step 5".

Run the JOM in the console.

$D:/jom_1_1_3/jom.exe

10. Install the QT SDK to the local.


$nmake install

In the "step 7", we set the install path is "D:\Qt_static". After this command, it will help to install QT to this folder.

Reference: https://blog.csdn.net/zhangpeterx/article/details/105099003

2023年2月3日 星期五

Windows 10 - System Built-in MD5 Tool

certutil -hashfile <filename> <hash-mode>

certutil -?

Verbs:
 -dump          -- Dump configuration information or files
 -asn           -- Parse ASN.1 file
 -decodehex     -- Decode hexadecimal-encoded file
 -decode        -- Decode Base64-encoded file
 -encode        -- Encode file to Base64
 -deny          -- Deny pending request
 -resubmit      -- Resubmit pending request
 -setattributes -- Set attributes for pending request
 -setextension  -- Set extension for pending request
 -revoke        -- Revoke Certificate
 -isvalid       -- Display current certificate disposition
 -getconfig     -- Get default configuration string
 -ping          -- Ping Active Directory Certificate Services Request interface
 -pingadmin     -- Ping Active Directory Certificate Services Admin interface
 -CAInfo        -- Display CA Information
 -ca.cert       -- Retrieve the CA's certificate
 -ca.chain      -- Retrieve the CA's certificate chain
 -GetCRL        -- Get CRL
 -CRL           -- Publish new CRLs [or delta CRLs only]
 -shutdown      -- Shutdown Active Directory Certificate Services
 -installCert   -- Install Certification Authority certificate
 -renewCert     -- Renew Certification Authority certificate
 -schema        -- Dump Certificate Schema
 -view          -- Dump Certificate View
 -db            -- Dump Raw Database
 -deleterow     -- Delete server database row
 -backup        -- Backup Active Directory Certificate Services
 -backupDB      -- Backup Active Directory Certificate Services database
 -backupKey     -- Backup Active Directory Certificate Services certificate
                   and private key
 -restore       -- Restore Active Directory Certificate Services
 -restoreDB     -- Restore Active Directory Certificate Services database
 -restoreKey    -- Restore Active Directory Certificate Services certificate
                   and private key
 -importPFX     -- Import certificate and private key
 -dynamicfilelist -- Display dynamic file List
 -databaselocations -- Display database locations
 -hashfile      -- Generate and display cryptographic hash over a file
 -store         -- Dump certificate store
 -addstore      -- Add certificate to store
 -delstore      -- Delete certificate from store
 -verifystore   -- Verify certificate in store
 -repairstore   -- Repair key association or update certificate properties or
                   key security descriptor
 -viewstore     -- Dump certificate store
 -viewdelstore  -- Delete certificate from store
 -dsPublish     -- Publish certificate or CRL to Active Directory
 -ADTemplate    -- Display AD templates
 -Template      -- Display Enrollment Policy templates
 -TemplateCAs   -- Display CAs for template
 -CATemplates   -- Display templates for CA
 -enrollmentServerURL -- Display, add or delete enrollment server URLs associated
                   with a CA
 -ADCA          -- Display AD CAs
 -CA            -- Display Enrollment Policy CAs
 -Policy        -- Display Enrollment Policy
 -PolicyCache   -- Display or delete Enrollment Policy Cache entries
 -CredStore     -- Display, add or delete Credential Store entries
 -InstallDefaultTemplates -- Install default certificate templates
 -URLCache      -- Display or delete URL cache entries
 -pulse         -- Pulse autoenrollment events
 -MachineInfo   -- Display Active Directory machine object information
 -DCInfo        -- Display domain controller information
 -EntInfo       -- Display enterprise information
 -TCAInfo       -- Display CA information
 -SCInfo        -- Display smart card information
 -SCRoots       -- Manage smart card root certificates
 -verifykeys    -- Verify public/private key set
 -verify        -- Verify certificate, CRL or chain
 -sign          -- Re-sign CRL or certificate
 -vroot         -- Create/delete web virtual roots and file shares
 -vocsproot     -- Create/delete web virtual roots for OCSP web proxy
 -addEnrollmentServer -- Add an Enrollment Server application
 -deleteEnrollmentServer -- Delete an Enrollment Server application
 -oid           -- Display ObjectId or set display name
 -error         -- Display error code message text
 -getreg        -- Display registry value
 -setreg        -- Set registry value
 -delreg        -- Delete registry value
 -ImportKMS     -- Import user keys and certificates into server database for key
                   archival
 -ImportCert    -- Import a certificate file into the database
 -GetKey        -- Retrieve archived private key recovery blob
 -RecoverKey    -- Recover archived private key
 -MergePFX      -- Merge PFX files
 -ConvertEPF    -- Convert PFX files to EPF file
 -?             -- Display this usage message

CertUtil -?          -- Display a verb list (command list)
CertUtil -dump -?    -- Display help text for the "dump" verb
CertUtil -v -?       -- Display all help text for all verbs

CertUtil: -? command completed successfully.

2017年6月20日 星期二

Linux - How to find the GPIO usage status ?

$cat /sys/kernel/debug/gpio

GPIOs 576-607, platform/qcom,smp2pgpio-ssr-smp2p-4-out.19, master-kernel:

GPIOs 608-639, platform/qcom,smp2pgpio-ssr-smp2p-4-in.18, slave-kernel:

GPIOs 640-671, platform/qcom,smp2pgpio-ssr-smp2p-1-out.13, master-kernel:

GPIOs 672-703, platform/qcom,smp2pgpio-ssr-smp2p-1-in.12, slave-kernel:

GPIOs 704-735, platform/qcom,smp2pgpio-smp2p-4-out.16, smp2p:

GPIOs 736-767, platform/qcom,smp2pgpio-smp2p-4-in.14, smp2p:

GPIOs 768-799, platform/qcom,smp2pgpio-smp2p-1-out.10, smp2p:

GPIOs 800-831, platform/qcom,smp2pgpio-smp2p-1-in.8, smp2p:

GPIOs 832-863, platform/qcom,smp2pgpio-smp2p-7-out.6, smp2p:

GPIOs 864-895, platform/qcom,smp2pgpio-smp2p-7-in.4, smp2p:

GPIOs 896-899, spmi/qpnp-pin-ffffffc03161cc00, pm8916-gpio:
 gpio-896 (qcom,hub-reset-gpio ) out hi
 gpio-897 (qcom,sw-sel-gpio    ) in  lo

GPIOs 900-901, spmi/qpnp-pin-ffffffc03161c800, pm8916-mpp:

GPIOs 902-1023, platform/1000000.pinctrl, msm_tlmm_gpio:
 gpio-922 (adv7533_hpd_irq_gpio) in  lo
 gpio-923 (led1                ) out lo
 gpio-927 (disp_rst_n          ) in  lo
 gpio-933 (adv7533_irq_gpio    ) in  lo
 gpio-934 (adv7533_switch_gpio ) out lo
 gpio-940 (7864900.sdhci cd    ) in  hi
 gpio-1009 (volume_up           ) in  hi
 gpio-1012 (USB_ID_GPIO         ) in  hi
 gpio-1022 (led2                ) out lo

reference : https://stackoverflow.com/questions/16033748/how-do-can-i-find-out-which-linux-driver-is-hogging-my-gpio

2016年8月29日 星期一

Gitlab - 如何解決 "No authentication methods configured on login page" ? (gitlab version : 8.11.2)

1. 安裝 postgresql-client-common & postgresql-client

$sudo apt-get install postgresql-client postgresql-client-common

2. 連線資料庫

$sudo gitlab-psql gitlabhq_production

PS. 可以用 sudo gitlab-psql -l 查看資料庫列表

3. 進入 client 界面後輸入:

UPDATE application_settings set signin_enabled=true;
\q
4. 重新啟動 gitlab

$sudo gitlab-ctl restart

2016年8月17日 星期三

Spotify - 解決 ubuntu 16.04 下無法播放本機檔案問題

1. Download Spotify Library

$wget https://github.com/ramedeiros/spotify_libraries/archive/master.zip

or

$git clone https://github.com/ramedeiros/spotify_libraries.git

2. Copy files to lib folder.

$cd spotify_libraries
$sudo cp lib* /usr/lib/x86_64-linux-gnu/

3. link library

$sudo ldconfig
$sudo ln -frs /usr/lib/x86_64-linux-gnu/libavutil.so.52.6.100 /usr/lib/x86_64-linux-gnu/libavutil.so.52
$sudo ln -frs /usr/lib/x86_64-linux-gnu/libavformat.so.54.36.100 /usr/lib/x86_64-linux-gnu/libavformat.so.54
$sudo ln -frs /usr/lib/x86_64-linux-gnu/libavcodec.so.54.71.100 /usr/lib/x86_64-linux-gnu/libavcodec.so.54

Reference :
1. https://community.spotify.com/t5/Desktop-Linux-Windows-Web-Player/Linux-Local-files-do-not-play-on-Ubuntu-16-04-SOLVED/td-p/1343831
2. https://github.com/ramedeiros/spotify_libraries

2016年5月26日 星期四

MPLABX - 如何解決 MPLABX 在 Linux 版本下 editor 字體模糊問題?

1. 找到 MPLABX 安裝路徑,以 v3.15 在 ubuntu 16.04 為例:

$cd /opt/microchip/mplabx/v3.15/

2. 找到 ide 安裝路徑並且編輯設定檔

$sudo vim mplab_ide/etc/mplab_ide.conf

3. 修改設定值

default_options="-J-Dcrownking.stream.verbosity=very-quiet -J-Xss2m -J-Xms256m -J-XX:PermSize=128m -J-XX:MaxPermSize=384m -J-Dapple.awt.graphics.UseQuartz=true -J-XX:+CMSClassUnloadingEnabled -J-Dapt.limit.expanded.params=1000 -J-Dplugin.manager.check.interval=EVERY_DAY"

修改為...

default_options="-J-Dcrownking.stream.verbosity=very-quiet -J-Xss2m -J-Xms256m -J-XX:PermSize=128m -J-XX:MaxPermSize=384m -J-Dapple.awt.graphics.UseQuartz=true -J-XX:+CMSClassUnloadingEnabled -J-Dapt.limit.expanded.params=1000 -J-Dplugin.manager.check.interval=EVERY_DAY -J-Dawt.useSystemAAFontSettings=on"

4. 重開 MPLABX

2015年10月30日 星期五

Laravel - How to install Laravel 5 into ubuntu 14.04 ?

1. Install LAMP

$ sudo apt-get install python-software-properties
$ sudo apt-get update 
$ sudo apt-get install -y php5 php5-mcrypt
$ sudo apt-get install apache2 libapache2-mod-php5
$ sudo apt-get install mysql-server php5-mysql

2. Install Composer
$ curl -sS https://getcomposer.org/installer | php
$ sudo mv composer.phar /usr/local/bin/composer 
$ sudo chmod +x /usr/local/bin/composer

3. Install Laravel
$ cd /var/www/html
$ sudo git clone https://github.com/laravel/laravel.git
$ cd /var/www/html/laravel
$ sudo composer install
$ sudo chown -R www-data.www-data /var/www/html/laravel
$ sudo chmod -R 755 /var/www/html/laravel 

4. Create .env and replace key into it.
$ cd /var/www/html/laravel
$ sudo cp .env.example .env
$ sudo chown www-data:www-data .env
$ php artisan key:generate

You will get the new key, like ...
Application key [pY5f1IYsOEqg6JxksaKF1gXGdMY1Z3w1] set successfully
Please copy this key and assign this key into "APP_KEY" on ".env"
PS. DON"T COPY MY KEY INTO YOUR SETTING !!!

5. Restart apache2 server
$ sudo service apache2 restart

6. Open your browser with "127.0.0.1/laravel/public"

2015年10月2日 星期五

ubuntu - How to setting the LTIB on ubuntu 14.04

1. Install all build tool into your host PC.

$ sudo apt-get install gettext libgtk2.0-dev rpm bison m4 libfreetype6-dev
$ sudo apt-get install libdbus-glib-1-dev liborbit2-dev intltool
$ sudo apt-get install ccache ncurses-dev zlib1g zlib1g-dev gcc g++ libtool
$ sudo apt-get install uuid-dev liblzo2-dev
$ sudo apt-get install tcl dpkg
$ sudo apt-get install asciidoc texlive-latex-base dblatex xutils-dev
$ sudo apt-get install texlive texinfo
$ sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0
$ sudo apt-get install libc6-dev-i386
$ sudo apt-get install u-boot-tools
$ sudo apt-get install scrollkeeper
$ sudo ln -s /usr/lib/x86_64-linux-gnu/librt.so /usr/lib/librt.so
$ sudo apt-get install gparted
$ sudo apt-get install nfs-common nfs-kernel-server
$ sudo apt-get install git-core git-doc git-email git-gui gitk
$ sudo apt-get install meld atftpd

2. Install LTIB into your host PC.
$ cd ~
$ tar -zxvf L3.0.35_4.1.0_130816_source. tar.gz
$ ./L3.0.35_4.1.0_130816_source/install

3. Apply the patch file.
$ cd ~/ltib
$ git apply 0001_make_L3.0.35_4.1.0_compile_on_Ubuntu_14.04_64bit_OS

4. Run the LTIB on host PC.
$ cd ~/ltib
$ ./ltib -m config
$ ./ltib

Reference : https://community.freescale.com/docs/DOC-100725

2015年10月1日 星期四

ubuntu - How to create the ubuntu rootfs for arm ?


1. Install "debootstrap" into your ubuntu system.
$sudo apt-get install debootstrap

2. Create the ubuntu core file system.
$sudo debootstrap --arch=armhf --keyring=/usr/share/keyrings/ubuntu-archive-keyring.gpg --verbose --foreign trusty rootfs

3. Install "qemu" into your ubuntu system.
$sudo apt-get install binfmt-support qemu qemu-user-static

4. Copy the qwmu-arm-static into your target file system.
$sudo cp /usr/bin/qemu-arm-static rootfs/usr/bin

5. Change root to your target file sytem.
$sudo chroot rootfs /bin/bash

6. Create the target file system without on arm.
$/debootstrap/debootstrap --second-stage

7. Next time, you can use "apt-get" to install any deb into target file system on host pc.

Reference:http://berniechenopenvpn.blogspot.tw/2015/07/filesystem.html

2015年8月14日 星期五

ubuntu - Enable PHP in HTML or other files

1. Created a file : .htaccess on your folder.
2. Add below to .htaccess :

$vim .htaccess

AddType application/x-httpd-php .html .htm
3. Modify "apache2.conf".

$vim apache2.conf

AllowOverride None => AllowOverride All
4. Restart apache2.

$sudo service apache2 restart

Reference : http://www.bictor.com/2015/03/03/enable-php-in-html-or-other-files/

2015年7月15日 星期三

Android - How to build the AOSP Nexus 7 (2012) ?

1. Get source code from AOSP.

$mkdir nexus_7_2012
$cd nexus_7_2012

You must to check nexus 7 (2012) and aosp version:
http://source.android.com/source/build-numbers.html#source-code-tags-and-builds

For example, if you want get android 5.1.1 for nexus 7 (2012) wifi only source code, you can find ...


Because nexus 7 2012 wifi device name was "grouper", we can find the branch is android-5.1.1_r1.

$repo init -u https://android.googlesource.com/platform/manifest -b android-5.1.1_r1
$repo sync

2. Get third-party binaries.

Get binaries from this address : https://developers.google.com/android/nexus/drivers
We want to build the android 5.1.1 , so we must to get ...


After get these files, please copy to your aosp folder and execute.
You will to get the new folder "vendor" in your source code folder.

3. Build the source code.

$source build/envsetup.sh

Find the device tag and name from this ...
http://source.android.com/source/building-devices.html

"full_grouper-userdebug" was "nexus 7 2012 wifi only" configuration name.


$lunch lunch full_grouper-userdebug

$make -j8

4. Flash to device. (Your device must to oem unlock.)

$adb reboot-bootloader
$fastboot -w flashall

PS. You must to input cmd on aosp folder.

2015年2月3日 星期二

ubuntu - 在 ubuntu 上不利用 WINE 運作 Line (Pidgin + purple-line)

使用 WINE 跑 LINE 常常都會因為奇怪的原因 Crash 掉。找了很久,終於找到一篇日文的教學文章。這篇文章提供 Pidgin + purple-line 的外掛方式運行 Line 。經過測試之後是可行的。

測試環境 Ubuntu 14.04 x86_64 3.13.0-40-generic

1. 安裝 Pidgin

$ sudo apt-get install pidgin

2. 安裝編譯環境

$ sudo apt-get install libpurple0 libpurple-dev libpurple-bin
$ sudo apt-get install libboost-dev libboost-test-dev libboost-program-options-dev libevent-dev automake libtool flex bison pkg-config g++ libssl-dev python-dev

3. 下載 thrift ( http://www.apache.org/dyn/closer.cgi?path=/thrift/0.9.2/thrift-0.9.2.tar.gz )
4. 解壓縮 thrift

$ tar zxvf thrift-0.9.2.tar.gz

5. 編譯與安裝 thrift

$ cd thrift-0.9.2/
$ ./configure --without-tests
$ make
$ sudo make install

6. 下載 purple-line 的外掛

$ cd ~/
$ git clone http://altrepo.eu/git/purple-line.git/
$ cd purple-line/
$ wget http://altrepo.eu/git/line-protocol.git/blob_plain/HEAD:/line_main.thrift
$ make
$ make install
$ sudo ldconfig

接下來重新開機之後,就可以啟動 Pidgin 並且新增 Line 的帳號了。

參考文章:http://blog.livedoor.jp/hiroumauma/archives/1710677.html

2014年10月2日 星期四

Linux - warning: override XXX

Because your kconfig have "choice" !

This mean that only have "1" module can be enable.
But, you enabled 2 or more module on your config file belong this item.

After "make xxxx_config", it found 2 enable module on this item.

it will show ... warning: override.

You must to disable unnecessary module on this item.

2014年4月15日 星期二

How to install line on ubuntu ?

1. sudo add-apt-repository ppa:ubuntu-wine/ppa
2. sudo apt-get update
3. sudo apt-get install wine
4. winetricks vcrun2008
5. Download Line and install from http://cdn.line-apps.com/client/win/LineInst.exe

Reference : http://longbao738.blogspot.tw/2013/10/ubuntu-line.html

2014年2月22日 星期六

Python - How to install mysql-python on ubuntu?

$> sudo apt-get install python-dev

$> sudo apt-get install libmysqlclient-dev

$> pip install mysql-python

Reference :

1. http://lucaswei.blogspot.tw/2012/02/pythonh-no-such-file-or-directory.html
2. http://stackoverflow.com/questions/5178292/pip-install-mysql-python-fails-with-environmenterror-mysql-config-not-found

Python - How to install MySQL-python on MAC ?

1. Open console on mac.

2. Input cmd ...

$> pip install MySQL-python

$> sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /Library/Python/2.7/site-packages/_mysql.so

$> sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /Directories/To/File/filereferencedinpython

3. Add setting ..

export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/

Reference :

1. http://moravec.net/2013/04/installing-mysql-python-on-mac-os-x/
2. http://coddswallop.wordpress.com/2012/08/23/solving-library-not-loaded-libmysqlclient-18-dylib-when-importing-mysqldb-on-lion/

Python - How to install pip on MAC ?

1. Open console on mac

2. input the cmd on console:


$> sudo easy_install

Reference : http://stackoverflow.com/questions/17271319/installing-pip-on-mac-os-x

MySQL - How to install MySQL on MAC ?

1. Download the install dmg file from MySQL web side :

http://dev.mysql.com/downloads/mysql/

PS. please download the "MySQL Community Server"  mac version.

2. After double click the dmg file, you must to install the 2 pkg and 1 prefPane.

3. Modify the default password of MySQL :

(1) Open mac console mode.

(2) cd /usr/local/mysql/bin

(3) ./mysqladmin -h localhost -u root password

4. Add path of bin into your environment parameter.

(1) sudo vim /etc/bashrc

(2) Add "export PATH=$PATH:/usr/local/mysql/bin"
Reference : 
1. http://f.pil.tw/thread-108370-1-1.html
2. http://dev.mysql.com/downloads/mysql/