Home >Database >Mysql Tutorial >Detailed explanation of deletion/installation/encoding configuration file configuration of MySQL 5.6 version under Ubuntu

Detailed explanation of deletion/installation/encoding configuration file configuration of MySQL 5.6 version under Ubuntu

黄舟
黄舟Original
2017-06-18 10:57:561192browse

这篇文章主要介绍了ubuntu mysql 5.6版本的删除安装,编码配置文件配置,需要的朋友可以参考下

1. 删除MySQL


a. sudo apt-get autoremove --purge mysql-server*
b. sudo apt-get remove mysql-server
c. sudo apt-get autoremove mysql-server
d. sudo apt-get remove mysql-common (非常重要)

上面的其实有一些是多余的,建议还是按照顺序执行一遍

2. 清理残留数据


dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P

3. 安装 mysql


a. sudo apt-get install mysql-server
b. sudo apt-get install mysql-client
c. sudo apt-get install php5-mysql(安装php5-mysql是将php和mysql连接起来 )

安装完后可以mysql服务就启动了,也可以通过以下命令对管理mysql服务


service mysql start (启动mysql) 
service mysql stop  (关闭mysql) 
service mysql restart (重启mysql)

使用如下命令进入mysql中


mysql -u root -p 123456 (123456为自己设置的密码)

查看编码


show variables like '%character%'; 
[python] view plain copy
mysql> show variables like 'character%'; 
+--------------------------+----------------------------+ 
| Variable_name      | Value           | 
+--------------------------+----------------------------+ 
| character_set_client   | utf8            | 
| character_set_connection | utf8            | 
| character_set_database  | latin1           | 
| character_set_filesystem | binary           | 
| character_set_results  | utf8            | 
| character_set_server   | latin1           | 
| character_set_system   | utf8            | 
| character_sets_dir    | /usr/share/mysql/charsets/ | 
+--------------------------+----------------------------+

会发现有些编码是latin1,会导致中文乱码的问题,下面修改编码配置


cd /etc/mysql/my.cnf (编码的修改上要注意自己的mysql版本和系统,有可能不同) 
sudo chmod 775 my.cnf 
sudo vim my.cnf

在文件后面添加如下内容


[python] view plain copy
[mysqld] 
character-set-server=utf8

ESC + :wq 保存退出

使用service mysql restart 重启mysql 服务即可

The above is the detailed content of Detailed explanation of deletion/installation/encoding configuration file configuration of MySQL 5.6 version under Ubuntu. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn