此配制仅限于ubuntu下apt-get安装mysql;
1、支持中文:
进入mysql,查看字符集
mysql>
show variables like
'%char%'
;
1)进入:/etc/mysql/conf.d/mysql.conf
在 [mysql] 的下方加入下面的语句(这个文件只有一行 [mysql]):
no-auto-rehash
default-character-set=utf8
2)进入:/etc/mysql/mysql.conf.d/mysql.cnf
在 [mysqld] 下加入下面这句:
character-set-server=utf8
3)重启mysql服务: sudo /etc/init.d/mysql restart
查看mysql字符集:
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)
2、外网访问
1、默认mysql只允许本地访问
进入目录:/etc/mysql/mysql.conf.d
查看mysqld.cnf文件;
将 bind-address 配置 "127.0.0.1" 修改为 "0.0.0.0"
2、
进入mysql服务,输入下面命令:
mysql> use mysql;
mysql > select Host, User from user;
可见Host字段值为localhost;
修改所需要的用户接受登录的地址:
"%"为接受所有
示例,输入下面命令即可:
mysql> update user set host = "%" where user = root;
3、重启mysql服务: sudo /etc/init.d/mysql restart