LoginSignup
0
0

More than 1 year has passed since last update.

MySQLのコマンド

Last updated at Posted at 2021-10-07

#MySQLの起動・停止

MySQLのバージョン確認
$ mysql --version
または
$ systemctl status mysqld.service

サーバーを起動
$ mysql.server start
または
$ sudo systemctl start mysqld

サーバーを停止
$ mysql.server stop
または
$ sudo systemctl stop mysqld

#MySQLに接続

テーブルとユーザを指定して接続(パスワードなし)
mysql -u ユーザ名

テーブルとユーザを指定して接続(パスワードあり)
mysql -u ユーザ名 -p

接続解除
exit

#データベース

データベース一覧
show databases;

データベース選択
use データベース名

#テーブル

テーブル一覧の表示
show tables;

テーブル構造の表示
desc テーブル名;

テーブルのオーナーの変更
alter table テーブル名 owner to オーナー名;

#ユーザー

ユーザー一覧(すべての項目)
SELECT * FROM mysql.user;

ユーザー一覧(ユーザー名、ホスト名のみ)
SELECT User,Host FROM mysql.user;

0
0
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
0
0