MySQL初始化及字符集设置

首次安装后:

1、初始化mysql

my.cnf文件包含数据存放目录和临时目录:

datadir        = /mnt/data/mysql/

tmpdir          = /mnt/data/tmp/

首先创建上述两个文件夹,然后进入/usr/bin

设置初始密码:mysqladmin -u root password 'new_password'

设置初始数据库:mysql_install_db --force

让mysql支持远程访问:

mysql->grant all privileges on *.* to root@'%' identified by 'your_password' with grant option;

mysql->flush privileges;

/etc/my.cnf 里修改bind-address=0.0.0.0

2、设置字符集(/etc/my.cnf)

[client] and [mysqld]

// add default-character-set

// mysql 5.5 版本添加character-set-server=utf8

default-character-set = utf8

字符集搜索结果如下:

(如果想更改某个字符集,输入如下):

mysql>SETcharacter_set_client=utf8;

mysql>SETcharacter_set_connection=utf8;

mysql>SETcharacter_set_database=utf8;

mysql>SETcharacter_set_results=utf8;

mysql>SETcharacter_set_server=utf8;

mysql>SETcollation_connection=utf8;

mysql>SETcollation_database=utf8;

mysql>SETcollation_server=utf8;

你可能感兴趣的:(MySQL初始化及字符集设置)