# yum install mariadb-server
# mysql_install_db --user=mysql # systemctl start mariadb
# mysqladmin -u root password 'mysql' # mysqladmin -u root -pmysql create LA # mysqlshow -pmysql +--------------------+ | Databases | +--------------------+ | information_schema | | LA | | mysql | | performance_schema | | test | +--------------------+
# mysql -u root -pmysql Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 5 Server version: 5.5.68-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> grant all privileges on LA.* to mysql@localhost identified by 'mysql'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> quit Bye
# mysql -u mysql -pmysql Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 7 Server version: 5.5.68-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> quit Bye
$ mysql –u mysql -pmysql LA mysql> CREATE TABLE staff ( -> id int(3), -> name text, -> branch text, -> age int(3), -> PRIMARY KEY (id) -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT 'LPIC-1 Sample'; -> INSERT INTO staff (id,name,branch,age) VALUES -> ('1','Aoki','Tokyo','26'), -> ('2','Baba','Yokohama','31'), -> ('3','Chihara','Nagoya','20'), -> ('4','Deguchi','Yokohama','33'), -> ('5','Endo','Osaka','25'), -> ('6','Fujikawa','Tokyo','38'), -> ('10','Hato','Tokyo','19'), -> ('11','Abe','Yokohama','29'); mysql> CREATE TABLE IF NOT EXISTS books ( -> id int(3), -> category text, -> title text, -> auther text, -> PRIMARY KEY (id) -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT 'LPIC-1 14-1'; -> INSERT INTO books (id,category,title,auther) VALUES -> ('1','Linux','Shell Script Handbook','Ichiro Kato'), -> ('2','CCNA','Cisco Unifid Communication','Taro Yamada'), -> ('3','Linux','The NFS administration','Ken Tompson'), -> ('4','Programming','PHP basics','John Hollbe'), -> ('5','Programming','Introduction Ruby','Ichiyo Takano'), -> ('6','CCNA','The Layer 2','Kenichi Matsuda'); mysql> quit;
# bash sqlsetup.sh (上記の作業全てを一括して実行) # mysql -u mysql -pmysql LA (SQL の演習)