1. to remove MySQL 5.0, see previous post.
2. download the MySQL 4.1.22 installer from MySQL website.
3. install mysql-standard-4.1.22...i686.pkg
4. install mysqlStartupItem.pkg
5. set up MySQL config. In command prompt type:
sudo pico /etc/my.cnf
6. paste the following 4 lines into pico:
[mysqld]
default-character-set=utf8
[client]
default-character-set=utf8
7. exit pico & save file (ctrl+x, Yes for save)
8. now we can start the MySQL server using sudo:
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
9. open up command prompt, and enter mysql by typing:
/usr/local/mysql/bin/mysql -u root
EDIT: Getting it to work with OSX's installation of PHP...
Only follow the following instructions if you are having problems with the @mysql_connect method in PHP.
1. create a info.php file that calls the phpinfo(); method
----- NOTE: my version of PHP is 5.2.8
----- scroll down to the mysql section, and look for the value for key: MYSQL_SOCKET
----- MYSQL_SOCKET = /var/mysql/mysql.sock
----- goto /var/mysql and make sure mysql.sock... if the directory is missing or file is missing, you have the same problem I did. Your mysql.sock is probably inside /private/tmp...
2. in command prompt, type the following:
sudo mkdir /var/mysql
sudo chown _mysql /var/mysql
3. (OPTIONAL) in command prompt, type the following:
cp /private/tmp/mysql.sock /var/mysql/mysql.sock
4. edit the my.cnf file again, this time make sure its whole contents are the following 6 lines:
[client]
default-character-set=utf8
socket = /var/mysql/mysql.sock
[mysqld]
default-character-set=utf8
socket = /var/mysql/mysql.sock
5. restart the apache service through System Preferences > Sharing > Web Sharing
6. restart the MySQL service by typing the following 2 lines (one at a time) into command prompt:
sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
At this point the mysql_connect() php method should work as expected...
MYSQL: Removing MYSQL from a mac
Do the following in the terminal:
1. sudo rm /usr/local/mysql
2. sudo rm -rf /usr/local/mysql*
3. sudo rm -rf /Library/StartupItems/MySQLCOM
4. sudo rm -rf /Library/PerformancePanes/My*
5. (Edit /etc/hostconfig) sudo vi /etc/hostconfig (Remove line MYSQLCOM=-YES)
6. sudo rm -rf /Library/Reciepts/mysql*
7. sudo rm -rf /Library/Reciepts/MySQL*
1. sudo rm /usr/local/mysql
2. sudo rm -rf /usr/local/mysql*
3. sudo rm -rf /Library/StartupItems/MySQLCOM
4. sudo rm -rf /Library/PerformancePanes/My*
5. (Edit /etc/hostconfig) sudo vi /etc/hostconfig (Remove line MYSQLCOM=-YES)
6. sudo rm -rf /Library/Reciepts/mysql*
7. sudo rm -rf /Library/Reciepts/MySQL*
SQL: MySQL + USERS + MAC
when installing mysql for the very first time, you will need to create a root password in order to enter the mysql database:
mysqladmin -u ROOT_USER_NAME -p ROOT_PASSWORD
sign into mysql using the following command:
mysql --user=ROOT_USER_NAME --password=ROOT_PASSWORD
once in, you want to first navigate to the mysql database:
use mysql;
you can now insert more users to your liking by using the following commands:
create user 'SUB_USER_NAME'@'LOCALHOST';
set that person's password by using:
set password for 'SUB_USER_NAME'@'LOCALHOST' = PASSWORD('SUB_USER_PASSWORD');
now to give all permissions for the new user...
grant all privileges on *.* to 'SUB_USER_NAME'@'LOCALHOST' IDENTIFIED BY 'SUB_USER_PASSWORD' WITH GRANT OPTION;
or if you want to just grant certain privileges (in this case, SELECT):
grant SELECT on *.* to 'SUB_USER_NAME'@'LOCALHOST' IDENTIFIED BY 'SUB_USER_PASSWORD';
if you made a mistake, you can revoke the privileges by doing this:
revoke all privileges, grant option from 'SUB_USER_NAME'@'LOCALHOST';
NOTE:
1. *.* means you are granting permission to SELECT on all databases. Alternatively you could also specify a specific database, ie. mysql.user
2. GRANT OPTION is a special command that allows the SUB_USER to grant that same permission to other users
mysqladmin -u ROOT_USER_NAME -p ROOT_PASSWORD
sign into mysql using the following command:
mysql --user=ROOT_USER_NAME --password=ROOT_PASSWORD
once in, you want to first navigate to the mysql database:
use mysql;
you can now insert more users to your liking by using the following commands:
create user 'SUB_USER_NAME'@'LOCALHOST';
set that person's password by using:
set password for 'SUB_USER_NAME'@'LOCALHOST' = PASSWORD('SUB_USER_PASSWORD');
now to give all permissions for the new user...
grant all privileges on *.* to 'SUB_USER_NAME'@'LOCALHOST' IDENTIFIED BY 'SUB_USER_PASSWORD' WITH GRANT OPTION;
or if you want to just grant certain privileges (in this case, SELECT):
grant SELECT on *.* to 'SUB_USER_NAME'@'LOCALHOST' IDENTIFIED BY 'SUB_USER_PASSWORD';
if you made a mistake, you can revoke the privileges by doing this:
revoke all privileges, grant option from 'SUB_USER_NAME'@'LOCALHOST';
NOTE:
1. *.* means you are granting permission to SELECT on all databases. Alternatively you could also specify a specific database, ie. mysql.user
2. GRANT OPTION is a special command that allows the SUB_USER to grant that same permission to other users
IPHONE: NSXMLParser leak NSPlaceholderString
This is probably the most annoying leak I've every faced. With the NSXMLParser, I was getting these crazy 16 byte NSCFString leaks. The leaks traced back to [NSXMLParser parse], caused by NSPlaceholderString initWithBytes/initWithString.
I believe this is caused by the [parser:foundcharacters] method. Generally, the xml document being parsed has a bunch of \t and \n characters. It would appear these are the culprit. I got rid of the parse leaks by doing the following:
- (void)parser:(NSXMLParser*)parser foundCharacters:(NSString*)cdata {
NSString* tmp = [cdata stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if(curr && tmp && [tmp length] > 0) {
curr.content:tmp;
}
}
Where curr is the variable saving the cdata 'found characters'.
I believe this is caused by the [parser:foundcharacters] method. Generally, the xml document being parsed has a bunch of \t and \n characters. It would appear these are the culprit. I got rid of the parse leaks by doing the following:
- (void)parser:(NSXMLParser*)parser foundCharacters:(NSString*)cdata {
NSString* tmp = [cdata stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if(curr && tmp && [tmp length] > 0) {
curr.content:tmp;
}
}
Where curr is the variable saving the cdata 'found characters'.
Subscribe to:
Posts (Atom)