[ログインとログオフ]
[root@erp2 htdocs]# mysql -uroot -p
Enter password: [rootパスワード]
Server version: 5.5.60-MariaDB MariaDB Server
MariaDB [(none)]> exit
Bye
[DB作成]
MariaDB [(none)]> CREATE DATABASE db1 DEFAULT CHARACTER SET utf8;
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| db1 |
| mysql |
| performance_schema |
+--------------------+
[ユーザ作成]
MariaDB [(none)]> GRANT ALL PRIVILEGES ON db1.* TO db1_user@localhost IDENTIFIED BY 'db1_password';
[ログイン]
[root@erp2 htdocs]# mysql -udb1_user -pdb1_password;
[テーブル作成]
MariaDB [(none)]> use db1
MariaDB [db1]> CREATE TABLE table1 (\
-> id INT AUTO_INCREMENT PRIMARY KEY,\
-> name VARCHAR(255)\
-> );
MariaDB [db1]> show tables;
+---------------+
| Tables_in_db1 |
+---------------+
| table1 |
+---------------+
MariaDB [db1]> desc table1;
+-------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(255) | YES | | NULL | |
+-------+--------------+------+-----+---------+----------------+
[データ作成]
MariaDB [db1]> insert table1 set name='name1';
MariaDB [db1]> insert table1 set name='name2';
MariaDB [db1]> select * from table1;
+----+-------+
| id | name |
+----+-------+
| 1 | name1 |
| 2 | name2 |
+----+-------+