MySQL の設定について

MySQL の設定

root でログインしてユーザーを作成する

mysql> create user
    -> 'USERNAME'@'localhost' identified by 'hogehoge';
$ mysql -u USERNAME -p
Enter password: 

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
+--------------------+
1 row in set (0.00 sec)

↑権限がないので 1 つの DB しか見えていない

mysql> grant all on testdb.* to USERNAME@localhost;
mysql> flush privileges;

↑権限を付与する

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| testdb             |
+--------------------+
2 rows in set (0.00 sec)

↑testdb も見えるようになる

MySQL の設定ファイル my.cnf の場所
$ sudo find / -name my.cnf
/etc/mysql/my.cnf
少し編集する
[mysqld]
default-character-set = utf8
init-connect = "SET NAMES utf8"
language = /usr/share/mysql/japanese

port は 3306 番なのね。

忘れがちなのでメモ

PHP の設定ファイル

/etc/php5/apache2/php.ini

Apache の再起動

/etc/init.d/apache2 restart