インストール
apt-get install mysql-server
文字列をutf8にする
/etc/mysql/my.cnfのclientとmysqldに下記の様に設定する
[client] default-character-set = utf8 [mysqld] character-set-server = utf8
確認
# /etc/init.d/mysql restart # mysql -u root -p Enter password: .... mysql> show variables like 'char%'; +--------------------------+----------------------------+ | 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)
リモートログイン出来るように環境設定変更
/etc/mysql/my.cnfのbind-addressをコメントアウトするか、ログイン用IPを設定する
#bind-address = 127.0.0.1 bind-address = 192.168.1.2
ネットワーク(リモート)ログインユーザを追加する
# mysql -u root -p Enter password: .. mysql> grant all privileges on *.* to root@'192.168.1.2' identified by 'root' with grant option; mysql> select user, host from mysql.user; +------------------+---------------------------+ | user | host | +------------------+---------------------------+ | root | 127.0.0.1 | | root | 192.168.1.2 | | root | ::1 | | root | localhost | +------------------+---------------------------+ 8 rows in set (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
リモートからの接続
mysql -h 192.168.0.6 -u root -p
MySqlの開始・停止
/etc/init.d/mysqld stop /etc/init.d/mysqld start