LoginSignup
5
3

More than 5 years have passed since last update.

MySQLでよく使うSQLとかまとめ

Last updated at Posted at 2016-05-13

ユーザー確認

SELECT user,host,password FROM mysql.user;

SELECT user,host, authentication_string FROM mysql.user;

GRANT文

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'         IDENTIFIED BY 'password' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;

権限設定反映

FLUSH PRIVILEGES;

データベース作成

DROP DATABASE IF EXISTS database_name;
CREATE DATABASE database_name DEFAULT CHARACTER SET UTF8;

設定内容確認

SHOW VARIABLES;

# 例えば、文字コード周りの設定を確認する場合
SHOW VARIABLES LIKE 'character_set%';

パスワード設定

$ /usr/bin/mysqladmin -u root password 'your_secure_password'
5
3
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
5
3