ubuntu安装mysql数据库遇到的问题及解决办法

ubuntu安装mysql数据库遇到的问题及解决办法

1、安装完后启动mysql报错:
service mysql start 报错:Unknown job: mysql
解决办法: 参考:https://askubuntu.com/questions/296946/upstart-cant-start-mysql
首先:

   sudo touch /var/run/utmp
   sudo chmod 664 /var/run/utmp
   sudo reboot 

重启完成之后卸载mysql,然后再安装:

sudo apt-get purge mysql-server
sudo apt-get update
sudo apt-get install mysql-server 

接下来是关键的部分:

sudo apt-get purge mysql-server
sudo apt-get purge mysql-common
sudo rm -rf /var/log/mysql
sudo rm -rf /var/log/mysql.*
sudo rm -rf /var/lib/mysql
sudo rm -rf /etc/mysql
sudo apt-get install mysql-server --fix-missing --fix-broken

然后再打开mysql服务应该就不会报错了。

2、在sudo apt-get install mysql-workbench 的时候报错:
参考:https://askubuntu.com/questions/18806/why-does-update-mime-database-complain-about-uri-rtspt-and-other-unusual-types

Unknown media type in type 'all/all'
Unknown media type in type 'all/allfiles'
Unknown media type in type 'uri/mms'
Unknown media type in type 'uri/mmst'
Unknown media type in type 'uri/mmsu'
Unknown media type in type 'uri/pnm'
Unknown media type in type 'uri/rtspt'
Unknown media type in type 'uri/rtspu'
Unknown media type in type 'interface/x-winamp-skin'

貌似这是一个很老的bug了
解决办法:

sudo apt-get purge kdelibs-bin kdelibs-data 
sudo apt-get autoremove --purge
sudo update-mime-database /usr/share/mime

重新安装:

sudo apt-get purge mysql-workbench
sudo apt-get install mysql-workbench 

一切正常。

3、workbench中不能输入中文,或输入中文后为问号。

 解决办法:
 mysql> show variables like 'character%'; //执行编码显示,可以看到默认是latin1
 +--------------------------+----------------------------+ 

| Variable_name | Value |
+————————–+—————————-+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+————————–+—————————-+
修改/etc/mysql/my.cnf,分别在[client],[mysqld],[mysql]字段里添加default-character-set=utf8,character-set-server=utf8,default-character-set=utf8;
注意: [mysqld]中添加的是character-set-server=utf8!!!!!!!
修改完后service mysql restart重启mysql服务器。应该就能解决问题了。

你可能感兴趣的:(ubuntu,mysql)