Wednesday, February 1, 2012

Mysql installation on MAC OS X version 10.6.8


Hi,
Untar mysql in /usr/local/mysql  --> tar -zxvf filename .
As per instructions from INSTALL_BINARY (mysql) , we need to add groups , users , set permissions.

Once done , go to :

1. /usr/local/musql/bin
2. execute ./mysqladmin -u root -p Newpassword (Change root password for MySql)
3. ./mysql -u root -p
4. Enter new set password.

Once connected, you can list databases using

mysql> show databases;
mysql> use databasename;
mysql> show tables;
mysql> create table customer (custid INT , name TEXT);
mysql> insert into customer values(12,'Girish');

Database name --> test
Table name --> customer

While trying to connect using PHP we got following error :
------------------------------------------------------------
warning mysql_connect() function.mysql-connect 2002 no such file or directory (trying to connect via unix:///

Refer Link:
http://stackoverflow.com/questions/3968013/cakephp-no-such-file-or-directory-trying-to-connect-via-unix-var-mysql-mysq

Code :
--------


$con = mysql_connect("localhost","peter","abc123");
...
Error was with above line.

Solution :
----------
mysql defaults to use local unix domain sockets if you use localhost. Switching to the IP forces it to use TCP sockets instead

In above code insted of localhost we user 127.0.0.1 ip , and it worked Fine!!!!


Regards,
Girish

No comments:

Post a Comment