在ubuntu安装Mysql Server比较简单,一条命令就可以搞定,如下:
sudo apt-get install mysql-server
但是用apt-get安装mysql不能设置默认字符集,可能是我不明白怎么弄,安装完默认字符集是latin1,可以登录mysql后用status命令查看,显示内容如下:
root@ubuntu-vm:/home/kuuyee# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.0.51a-3ubuntu5.4 (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> status
--------------
mysql Ver 14.12 Distrib 5.0.51a, for debian-linux-gnu (i486) using readline 5.2
Connection id: 4
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.0.51a-3ubuntu5.4 (Ubuntu)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: latin1
Client characterset: latin1
Conn. characterset: latin1
UNIX socket: /var/run/mysqld/mysqld.sock
Uptime: 16 hours 33 min 45 sec
Threads: 1 Questions: 10 Slow queries: 0 Opens: 12 Flush tables: 1 Open tables: 6 Queries per second avg: 0.000
--------------
解决办法就是更改/etc/mysql/my.cnf文件,在[mysqld]和[mysql]下添加如下内容:
[mysqld]
default-character-set=utf8
default-storage-engine=INNODB
[mysql]
default-character-set=utf8
然后重启mysql server即可,命令如下:
sudo /etc/init.d/mysql restart
然后再查看一下status,呵呵!字符集变为utf-8了!