Monday, June 21, 2010

MySQL

1. mysqld_safe is the recommended way to start a mysqld server.
(sudo mysqld_safe)

2. initially, mysql password is not set. Set mysql password:
mysqladmin -u root password 'mypassword'

3. Create a database
:
mysqladmin -u root -p create jiansen_db

4. Create a superuser:
mysql --user=root -p mysql
(note mysql is not case sensitive)
mysql>CREATE USER 'jiansen'@'localhost' IDENTIFIED BY 'jiansen_passwd';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'jiansen'@'localhost' WITH GRANT OPTION;

5. Using user jiansen:
mysql --user=jiansen -p
mysql> show databases #comments;
mysql>use jiansen_db;
mysql>create table test_table1 (user_name char(32), passwd char(32));
mysql> show tables;
mysql>describe test_table1;
mysql>insert into test_table1 (user_name, passwd) values ('jiansen', 'jiansen');
mysql>select * from test_table1;
mysql>commit ;
mysql> quit;

6. The history file can be found:
~/.mysql_history


No comments:

Post a Comment