Skip to content

Instantly share code, notes, and snippets.

@masayuki-tsuji
Created June 8, 2018 13:18
Show Gist options
  • Save masayuki-tsuji/3d864138bd6fa94f5dca50551d34f6e3 to your computer and use it in GitHub Desktop.
Save masayuki-tsuji/3d864138bd6fa94f5dca50551d34f6e3 to your computer and use it in GitHub Desktop.
AWSのMySQL初期セットアップ ref: https://qiita.com/tu-kun/items/c1bca8e5fd38c69ea811
$ sudo service mysqld start
Starting mysqld: [ OK ]
$ mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.59 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show variables like "chara%";
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
mysql> create database studywebapp;
Query OK, 1 row affected (0.00 sec)
mysql> create user default_user@localhost identified by 'xxxxx';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all on studywebapp.* to default_user@localhost identified by 'xxxxx';
Query OK, 0 rows affected (0.00 sec)
$ mysql -u default_user -p -D studywebapp
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.5.59 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show variables like "chara%";
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
mysql> ALTER DATABASE studywebapp default character set utf8;
Query OK, 1 row affected (0.00 sec)
$ sudo vi /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mysqld according to the
# instructions in http://fedoraproject.org/wiki/Systemd
character-set-server=utf8 # 追加
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[client] #追加
default-character-set=utf8 #追加
$ sudo service mysqld restart
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment