mysql データベース メモ
接続(Windows)
D:\xxxxxx> mysql.exe -u root
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 7
Server version: 10.1.19-MariaDB mariadb.org binary distributionCopyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
データベース一覧・・・
MariaDB [(none)]> SHOW DATABASES;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- +
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Database |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- +
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
horserace |
information_schema |
mysql |
performance_schema |
phpmyadmin |
test |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- +
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
6 rows in set (0.00 sec)
horseraceにはどんなテーブルがあるのか・・・
MariaDB [(none)]> SHOW tables from horserace;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- +
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Tables_in_horserace |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- +
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
horse_races |
race_results |
race_results_harai |
races |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- +
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
4 rows in set (0.00 sec)
horserace に接続して・・・
MariaDB [(none)]> use horserace;
Database changed
race_resultsテーブルの設定を見てみる・・・
MariaDB [horserace]> SHOW create table race_results;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
:
) ENGINE=InnoDB DEFAULT CHARSET=sjis |
テーブル一個一個にcharset が設定できるとか、きめ細かいが使うとは思えん。
面倒だな・・・
一応デフォルトでは・・・
MariaDB [horserace]> SHOW create database horserace;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- +
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Database | Create Database |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- +
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
horserace | CREATE DATABASE `horserace` /*!40100 DEFAULT CHARACTER SET sjis */ |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- +
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
1 row in set (0.00 sec)というように無言の設定があるようだが。
DB自体の設定は・・・
MariaDB [horserace]> \s
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
mysql.exe Ver 15.1 Distrib 10.1.19-MariaDB, for Win32 (AMD64)
Connection id: 7
Current database: horserace
Current user: root@localhost
SSL: Not in use
Using delimiter: ;
Server: MariaDB
Server version: 10.1.19-MariaDB mariadb.org binary distribution
Protocol version: 10
Connection: localhost via TCP/IP
Server characterset: latin1
Db characterset: sjis
Client characterset: cp932
Conn. characterset: cp932
TCP port: 3306
Uptime: 2 hours 1 min 57 sec
Threads: 1 Questions: 53 Slow queries: 0 Opens: 22 Flush tables: 1 Open tab
les: 16 Queries per second avg: 0.007
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
接続に関しては・・・
MariaDB [horserace]> select user,host from mysql.user;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- +
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
user | host |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- +
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
root | 127.0.0.1 |
root | 192.168.3.3 |
root | 192.168.3.4 |
root | ::1 |
localhost | |
pma | localhost |
root | localhost |
www | localhost |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- +
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
8 rows in set (4.72 sec)で見れる。
IPv6でも設定できるみたい。
Linuxでは一発目の起動ができくて困ったが、ユーザ指定してないからで -u root でもできないので、多分普通にrootになってmysqlを立ち上げて、専用ユーザを作らなくてはならないみたい。
で
# mysql
:
:
mysql> CREATE USER www IDENTIFIED BY 'xxxx';
Query OK, 0 rows affected (0.06 sec)
が可能になる。
$ mysql -u www
あとはアクセス制限などを付けて準備完了。