在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了!