LoginSignup
3
8

More than 5 years have passed since last update.

mariaDB 初心者 チートシート

Last updated at Posted at 2017-11-06

Mysqlをインストールして起動するとなぜかmariaDBになったので
せっかくなので使ってみる。
入力する場所は、{ここの部分}

テンプレの作業工程

ログイン

ユーザ作成

DB作成

テーブル作成

データの登録

ログイン

$ mysql -u '{username}' -p

パスワードを入力してログイン
初期ログインは、スーパーユーザで

# mysql

だけで良い。

ユーザ作成

mariaDB[]> create user '{username}'@'localhost' identified by '{passwd}';

usernameとpasswdは同じ人が結構いる

ついでに権限も与える。
権限は、ALL権限を与える人が多い

mariaDB[]> grant all privileges on *.* to '{username}'@'localhost';

userの確認

mariaDB[]> select user,host FROM mysql.user;

userの削除

mariaDB[]> drop user FROM {user_name};

DB作成

mariaDB[]> create database {testdb};

テーブルの作成

まず、DBに入る

mariaDB[]> use {testdb}

テーブル作成

mariaDB[testdb]> create table {example_table}(num int,name varchar(50));

テーブルの確認

mariaDB[testdb]> show tables;

データの登録

mariaDB[testdb]>insert into {example_table} values(1, aaa);

mariaDB[testdb]>insert into {example_table} values(2, bbb);

データの確認

mariaDB[testdb]>select * from example_table;
output
+------+------+
| num  | name |
+------+------+
|    1 | aaa  |
|    2 | bbb  |
+------+------+
2 rows in set (0.00 sec)
3
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
8