Configure MySQL on OS X

In this article, I will show you how to configure MySQL self install. First, you have to make sure there is .bash_login file in your home directory, if the file not exist, just make it and open that file with:

edit .bash_login

Or you can using anything editor that you like most, it doesn’t matter ;p. MySQL installed in /usr/local/mysql directory, and changed to /usr/local/mysql-yourversion. If you want to start mysql by command line easily, you can add/edit .bash_login like below :

# Add the MySQL Home environment
export set MYSQL_HOME=/usr/local/mysql-yourversion

# Add mysql directory to home path
export set PATH=$PATH:$MYSQL_HOME/bin

# Make an alias to start and stop mysql
alias mysqlstart=”/Library/StartupItems/MySQLCOM/MySQLCOM start”
alias mysqlstop=”/Library/StartupItems/MySQLCOM/MySQLCOM stop”

After that you have to save and close editor, close your terminal too and then open new session terminal then input command like this :

which -a mysql

it should return your mysql directory :D. So, let’s go to the next step, connect to your MySQL as root

mysql -u root
use mysql;
SELECT USER,password, host FROM USER

command above will show you mysql and password username, if you want to changes it, just enter command below :

SET PASSWORD for ‘root’@’localhost’ = password(‘iamhandsome’);

Of course, you should not be follow me set password like that, it is not safe :p Do not forget to flush privileges MySQL to refresh your MySQL configuration. Now, you can enter MySQL admin with terminal and start/stop MySQL with command below

mysqlstart start
mysqlstart stop

Write a Comment


This site uses Akismet to reduce spam. Learn how your comment data is processed.