0[evett@localhost ~]$ mysql -u root ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) [evett@localhost ~]$ su Password: [root@localhost evett]# chkconfig bash: chkconfig: command not found [root@localhost evett]# locate chkconfig /usr/share/man/man8/chkconfig.8.gz /sbin/chkconfig [root@localhost evett]# /sbin/chkconfig mysqld on [root@localhost evett]# /etc/init.d/mysqld start Initializing MySQL database: [ OK ] Starting MySQL: [ OK ] [root@localhost evett]# exit exit [evett@localhost ~]$ mysql -u root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 to server version: 3.23.52 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> help; MySQL commands: Note that all text commands must be first on line and end with ';' help (\h) Display this help. ? (\?) Synonym for `help'. clear (\c) Clear command. connect (\r) Reconnect to the server. Optional arguments are db and host. edit (\e) Edit command with $EDITOR. ego (\G) Send command to mysql server, display result vertically. exit (\q) Exit mysql. Same as quit. go (\g) Send command to mysql server. nopager (\n) Disable pager, print to stdout. notee (\t) Don't write into outfile. pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. print (\p) Print current command. quit (\q) Quit mysql. rehash (\#) Rebuild completion hash. source (\.) Execute a SQL script file. Takes a file name as an argument. status (\s) Get status information from the server. tee (\T) Set outfile [to_outfile]. Append everything into given outfile. use (\u) Use another database. Takes database name as argument. Connection id: 1 (Can be used with mysqladmin kill) mysql> create database people; Query OK, 1 row affected (0.00 sec) mysql> show databases; +----------+ | Database | +----------+ | mysql | | people | | test | +----------+ 3 rows in set (0.00 sec) mysql> use people Database changed mysql> create table age_info ( -> lastname char(20), -> firstname char(20), -> age int -> ); Query OK, 0 rows affected (0.01 sec) mysql> show tables -> ; +------------------+ | Tables_in_people | +------------------+ | age_info | +------------------+ 1 row in set (0.00 sec) mysql> Suspended [evett@localhost ~]$ ls /var/lib/mysql mysql mysql.sock people test [evett@localhost ~]$ ls /var/lib/mysql/people ls: /var/lib/mysql/people: Permission denied [evett@localhost ~]$ su Password: [root@localhost evett]# ls /var/lib/mysql/people age_info.frm age_info.MYD age_info.MYI [root@localhost evett]# exit exit [evett@localhost ~]$ fg mysql -u root mysql> describe age_info -> ; +-----------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+----------+------+-----+---------+-------+ | lastname | char(20) | YES | | NULL | | | firstname | char(20) | YES | | NULL | | | age | int(11) | YES | | NULL | | +-----------+----------+------+-----+---------+-------+ 3 rows in set (0.00 sec) mysql> show columns from age_info -> ; +-----------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+----------+------+-----+---------+-------+ | lastname | char(20) | YES | | NULL | | | firstname | char(20) | YES | | NULL | | | age | int(11) | YES | | NULL | | +-----------+----------+------+-----+---------+-------+ 3 rows in set (0.00 sec) mysql> show columns -> ; ERROR 1064: You have an error in your SQL syntax near '' at line 1 mysql> use age_info ERROR 1049: Unknown database 'age_info' mysql> show databases; +----------+ | Database | +----------+ | mysql | | people | | test | +----------+ 3 rows in set (0.00 sec) mysql> use people Database changed mysql> show columns from age_info -> ; +-----------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+----------+------+-----+---------+-------+ | lastname | char(20) | YES | | NULL | | | firstname | char(20) | YES | | NULL | | | age | int(11) | YES | | NULL | | +-----------+----------+------+-----+---------+-------+ 3 rows in set (0.00 sec) mysql> insert into age_info -> (lastname, firstname, age) -> values('Evett','Matt', 41); Query OK, 1 row affected (0.00 sec) mysql> select * from age_info; +----------+-----------+------+ | lastname | firstname | age | +----------+-----------+------+ | Evett | Matt | 41 | +----------+-----------+------+ 1 row in set (0.03 sec) mysql> insert into age_info -> (lastname,firstname,age) -> values('evett','pete',39); Query OK, 1 row affected (0.00 sec) mysql> insert into age_info -> (lastname,firstname,age) -> values('rothleder','sarah',35); Query OK, 1 row affected (0.00 sec) mysql> select * from age_info -> ; +-----------+-----------+------+ | lastname | firstname | age | +-----------+-----------+------+ | Evett | Matt | 41 | | evett | pete | 39 | | rothleder | sarah | 35 | +-----------+-----------+------+ 3 rows in set (0.01 sec) mysql> select * from age_info order by firstname; +-----------+-----------+------+ | lastname | firstname | age | +-----------+-----------+------+ | Evett | Matt | 41 | | evett | pete | 39 | | rothleder | sarah | 35 | +-----------+-----------+------+ 3 rows in set (0.00 sec) mysql> select * from age_info where age > 38 order by age; +----------+-----------+------+ | lastname | firstname | age | +----------+-----------+------+ | evett | pete | 39 | | Evett | Matt | 41 | +----------+-----------+------+ 2 rows in set (0.02 sec) mysql> update age_info where firstname = 'sarah' set age=36; ERROR 1064: You have an error in your SQL syntax near 'where firstname = 'sarah' set age=36' at line 1 mysql> update age_info set age = 36 where firstname = 'sarah'; Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select * from age_info -> ; +-----------+-----------+------+ | lastname | firstname | age | +-----------+-----------+------+ | Evett | Matt | 41 | | evett | pete | 39 | | rothleder | sarah | 36 | +-----------+-----------+------+ 3 rows in set (0.00 sec) mysql> use mysql; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> grant select,insert,update,delete -> on people.* -> to evett -> identified by 'foobar'; Query OK, 0 rows affected (0.03 sec) mysql> quit Bye [evett@localhost ~]$ mysql -u evett -p Enter password: ERROR 1045: Access denied for user: 'evett@localhost' (Using password: YES) [evett@localhost ~]$ mysql -u evett -p Enter password: ERROR 1045: Access denied for user: 'evett@localhost' (Using password: YES) [evett@localhost ~]$ mysql -u root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 to server version: 3.23.52 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> show databases -> ; +----------+ | Database | +----------+ | mysql | | people | | test | +----------+ 3 rows in set (0.00 sec) mysql> use people; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> select *; ERROR 1096: No tables used mysql> show tables -> ; +------------------+ | Tables_in_people | +------------------+ | age_info | +------------------+ 1 row in set (0.01 sec) mysql> select * from age_info; +-----------+-----------+------+ | lastname | firstname | age | +-----------+-----------+------+ | Evett | Matt | 41 | | evett | pete | 39 | | rothleder | sarah | 36 | +-----------+-----------+------+ 3 rows in set (0.00 sec) mysql> create table addresses( -> lastname CHAR(20), -> firstname CHAR(20), -> address char(40), -> zipcode char(5)); Query OK, 0 rows affected (0.02 sec) mysql> insert into addresses -> (lastname,firstname,address,zipcode) -> values ("evett","pete","dallas","62011" -> ); Query OK, 1 row affected (0.03 sec) mysql> insert into addresses -> (lastname,firstname,address,zipcode) -> values ("evett","matt","ann arbor","48104" -> ) -> ; Query OK, 1 row affected (0.00 sec) mysql> insert into addresses -> (lastname,firstname,address,zipcode) -> values ("wilson","debbie","ann arbor","48104") -> ; Query OK, 1 row affected (0.00 sec) mysql> select * from age_info -> ; +-----------+-----------+------+ | lastname | firstname | age | +-----------+-----------+------+ | Evett | Matt | 41 | | evett | pete | 39 | | rothleder | sarah | 36 | +-----------+-----------+------+ 3 rows in set (0.01 sec) mysql> select * from addresses; +----------+-----------+-----------+---------+ | lastname | firstname | address | zipcode | +----------+-----------+-----------+---------+ | evett | pete | dallas | 62011 | | evett | matt | ann arbor | 48104 | | wilson | debbie | ann arbor | 48104 | +----------+-----------+-----------+---------+ 3 rows in set (0.00 sec) mysql> insert into addresses -> (lastname,firstname,address,zipcode) -> values ("rothleder","sarah","seattle","98001") -> ; Query OK, 1 row affected (0.00 sec) mysql> select * from addresses -> ; +-----------+-----------+-----------+---------+ | lastname | firstname | address | zipcode | +-----------+-----------+-----------+---------+ | evett | pete | dallas | 62011 | | evett | matt | ann arbor | 48104 | | wilson | debbie | ann arbor | 48104 | | rothleder | sarah | seattle | 98001 | +-----------+-----------+-----------+---------+ 4 rows in set (0.01 sec) mysql> select addresses.address -> from addresses, age_info -> where age_info.age < 40 and -> addresses.lastname = age_info.lastname -> and -> addresses.firstname = age_info.firstname; +---------+ | address | +---------+ | dallas | | seattle | +---------+ 2 rows in set (0.01 sec) mysql> quit Bye [evett@localhost ~]$ ls [evett@localhost ~]$ mysqldump -uevett -p people Enter password: mysqldump: Got error: 1045: Access denied for user: 'evett@localhost' (Using pas sword: YES) when trying to connect [evett@localhost ~]$ mysqldump -uroot -p people Enter password: -- MySQL dump 8.22 -- -- Host: localhost Database: people --------------------------------------------------------- -- Server version 3.23.52 -- -- Table structure for table 'addresses' -- CREATE TABLE addresses ( lastname char(20) default NULL, firstname char(20) default NULL, address char(40) default NULL, zipcode char(5) default NULL ) TYPE=MyISAM; -- -- Dumping data for table 'addresses' -- INSERT INTO addresses VALUES ('evett','pete','dallas','62011'); INSERT INTO addresses VALUES ('evett','matt','ann arbor','48104'); INSERT INTO addresses VALUES ('wilson','debbie','ann arbor','48104'); INSERT INTO addresses VALUES ('rothleder','sarah','seattle','98001'); -- -- Table structure for table 'age_info' -- CREATE TABLE age_info ( lastname char(20) default NULL, firstname char(20) default NULL, age int(11) default NULL ) TYPE=MyISAM; -- -- Dumping data for table 'age_info' -- INSERT INTO age_info VALUES ('Evett','Matt',41); INSERT INTO age_info VALUES ('evett','pete',39); INSERT INTO age_info VALUES ('rothleder','sarah',36);