After installing Postgres from official installer you’ll soon notice a new user on your Login screen, “Postgres”, to hide it perform the following:
sudo defaults write /Library/Preferences/com.apple.loginwindow HiddenUsersList -array-add postgres
After your log-out and login again you won’t be presented with that user, to reverse this change do:
sudo defaults delete /Library/Preferences/com.apple.loginwindow HiddenUsersList
More here
Here’s some useful commands for using MySQL from the command line, and breakdowns of the most common SQL query syntax.
h4. Command Line
mysql -u root@localhost p. login to mysql server with username ‘root’, host = localhost, this will drop you into a sql console where you can fire off common SQL queries & commands (e.g. select * from users, create table users…)
mysqladmin -u root password [mysqlpassword] p. change the ‘root’ password
mysqladmin -u root create sessions_development p. using ‘root’ account, create database ‘sessions_development’
mysqladmin -u root drop sessions_development p. using ‘root’ account, delete database ‘sessions_development’
mysqldump -u root -ppassword —opt >/all.sql p. backup all databases to disk
mysqldump -u root mydb > mydb.sql p. backup only database ‘mydb’ to disk
mysql -u username -ppassword mydb < /mydb.sql p. restore database mydb from disk
h4. Console Queries
CREATE TABLE new_tbl SELECT * FROM orig_tbl; p. create one table from the results of a SELECT query
CREATE TABLE people ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, fullname VARCHAR(255) ); p. creates a new table ‘people’ with an auto-incrementing (AUTO_INCREMENT) ‘id’ field that is the primary key (PRIMARY KEY) and can’t be null (NOT NULL), along with a ‘fullname’ variable text string field
INSERT INTO goods (price) VALUES (1.99); p. insert a new record into goods with the field ‘price’ of 1.99
UPDATE goods SET price = 2.99 WHERE name = ‘shampoo’; p. update ‘price’ value for record with ‘name’ of shampoo in ‘goods’ table
DROP TABLE IF EXISTS goods; p. conditionally only delete the table ‘goods’ if it exists
SHOW databases; p. list all databases on server
USE mydb; p. switch to another database
DESC goods; p. show table definition for ‘goods’ table
SHOW CREATE TABLE goods; p. show the sql syntax for creating the ‘goods’ table
DESCRIBE goods; p. to see all of table ‘goods’ field formats
FLUSH PRIVILEGES; p. update all database permissions & privileges
COMMIT; p. commit all pending transactions
ROLLBACK; p. rollback previous transaction