在Ubuntu12.04 以前的版本中配置MySQL數據庫很是方便,只須要運行3條命令便可:mysql
sudo apt-get install mysql-server sudo apt-get install mysql-admin sudo apt-get install mysql-query-browser
在ubuntu12.04 中只要執行兩條命令便可:sql
sudo apt-get install mysql-server sudo apt-get install mysql-workbench
sudo gedit /etc/mysql/my.cnf
在[mysqd]下面加入shell
character-set-server=utf8
保存,重啓mysql,執行下面語句查看字符編碼數據庫
sudo /etc/init.d/mysql restart mysql -uroot -p show variables like 'character%';
+--------------------------+----------------------------+ubuntu
| Variable_name | Value |編碼
+--------------------------+----------------------------+spa
| character_set_client | utf8 |rest
| character_set_connection | utf8 |code
| character_set_database | utf8 |server
| 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)
結果顯示已經正確設置爲UTF8字符編碼了。
create user ejbca IDENTIFIED BY 'ejbca'; GRANT ALL PRIVILEGES ON *.* TO ejbca@localhost;
上面語句會建立用戶:ejbca,並設置密碼爲ejbca,設置本機訪問的權限