Table of Contents
Linux下MySQL的彻底卸载和安装配置字符集
前言:
MySQL的彻底卸载
MySQL的安装
MySQL字符集的配置
注意
Home Database Mysql Tutorial Linux下MySQL的彻底卸载和安装配置字符集_MySQL

Linux下MySQL的彻底卸载和安装配置字符集_MySQL

Jun 02, 2016 am 08:49 AM
character set

Linux下MySQL的彻底卸载和安装配置字符集

前言:

Linux环境下MySQL的安装和配置在网上已经有很多教程了。之所以写这篇文章是因为在配置字符集的时候找了网上的一些教程发现并不能用导致折腾了一阵子。下面的教程均是亲自实践。

MySQL的彻底卸载

首先查看一下自己是否已经安装了MySQL。代码如下:
ps -aux|grep mysql
Copy after login
如未安装则不显示任何内容,若安装则会显示如下的信息:
\

关于mysql的彻底卸载有很多方法,人工去卸载和删除冗余文件比较麻烦,只需依次执行以下三条指令即可:
sudo apt-get autoremove --purge mysql-server-5.5

sudo apt-get remove mysql-common

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

这里一定要注意你的Mysql版本

MySQL的安装

最简单的安装方式就是命令行方式,依次输入一下代码即可:
sudo apt-get install mysql-server

sudo apt-get install mysql-client
Copy after login

在安装server时会提示你设置root的密码。 \

MySQL字符集的配置

首先我们在终端打开mysql:
mysql -uroot -p
Copy after login

然后输入密码即可进入mysql \

然后我们输入下面的查询语句来查看默认的字符集设置:
show variables like '%character%';
Copy after login

我们将看到一下结果: \

可以看出我们的character_set_database和character_set_server两处还未设置成utf8(或者GBK)。 下面我们只需要在mysql的配置文件修改即可。退出mysql之后在命令行输入以下代码编辑配置文件:
sudo vim /etc/mysql/my.cnf
Copy after login
如果没安装vim可以用系统自带的gedit打开:
sudo gedit /etc/mysql/my.cnf
Copy after login

下面只需要在两处修改即可!但要注意mysql5.5以下版本5.5以上版本有一处不同,一定要注意自己的版本! mysql5.5以下版本修改如下: 【client】 default-character-set = utf8 【mysqlddefault-character-set = utf8
mysql5.5以上版本修改如下: 【client】 default-character-set = utf8 【mysqld】 character-set-server = utf8 \

\

接下来,重启mysql使配置文件生效: 方式有两种: 方式1:
sudo /etc/init.d/mysql restart
Copy after login
\ 方式2:
sudo service mysql restart
Copy after login
\

接下来进入mysql,再来看一下字符集设置: \

可以看到除了system之外均该为了utf8.

注意

改字符集之前建立的数据库内的数据仍是中文乱码,这时我们备份一下数据新建即可。
Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Detailed explanation of how to modify the character set of Oracle database Detailed explanation of how to modify the character set of Oracle database Mar 02, 2024 pm 03:18 PM

Detailed explanation of how to modify the character set of Oracle database Oracle database is a powerful relational database management system that supports multiple character sets, including Simplified Chinese character set, Traditional Chinese character set, English character set, etc. In practical applications, you may encounter situations where you need to modify the database character set. This article will introduce in detail the method of modifying the Oracle database character set and provide specific code examples for readers' reference. 1. Check the current database character set. Before modifying the database character set, you first need to check the current database character set.

What are the tips for learning MySQL's character set and collation settings? What are the tips for learning MySQL's character set and collation settings? Jul 31, 2023 pm 03:18 PM

What are the tips for learning MySQL’s character set and collation settings? As a popular relational database management system, MySQL has very important character set and collation settings when processing data. Properly setting character sets and collation rules can ensure data integrity and consistency, while also improving query and sorting efficiency. This article will introduce some tips for learning MySQL character set and collation settings, and provide corresponding code examples. 1. Character set setting skills to view the current character set settings. Use the following command to view the current character set settings.

Oracle database character set modification steps and precautions Oracle database character set modification steps and precautions Mar 02, 2024 pm 09:27 PM

Title: Oracle Database Character Set Modification Steps and Precautions In the Oracle database, the character set is a very important setting, which determines the character types and encoding methods that can be supported by the data stored in the database. Sometimes, we need to modify the character set to adapt to new business needs or solve some data storage problems. This article will introduce in detail the steps and precautions for modifying the Oracle database character set, and will also provide specific code examples. 1. Character set modification steps: 1. Back up the database: before doing any data

MySql character set and sorting rules: how to solve the problem of Chinese garbled characters MySql character set and sorting rules: how to solve the problem of Chinese garbled characters Jun 16, 2023 am 08:51 AM

MySql is a very popular database management system, especially suitable for large-scale data storage and processing. However, when using MySql, we often encounter the problem of Chinese garbled characters. This is because the character set and collation of MySql are not set correctly. The following will introduce how to solve the problem of Chinese garbled characters. 1. MySql’s character set and collation rules MySql supports multiple character sets and collation rules. The character set determines which characters can be stored in the database, and the collation determines how these characters are sorted and compared.

Detailed introduction to Oracle character set modification and garbled code repair methods Detailed introduction to Oracle character set modification and garbled code repair methods Mar 03, 2024 am 09:00 AM

The character set setting in Oracle database is very important for data storage and retrieval. Correctly setting the character set can ensure the correctness and integrity of the data. In actual applications, sometimes due to some uncontrollable factors, character set mismatch may lead to garbled characters. This article will introduce in detail how to modify the character set in the Oracle database, and give specific methods and code examples to repair garbled characters. 1.Oracle character set modification method 1.1 To view the current character set in the Oracle database, you can use the following

How to verify specific character set using regular expression in golang How to verify specific character set using regular expression in golang Jun 24, 2023 pm 01:00 PM

In golang, validating a specific character set using regular expressions is a common task. This task involves the problem of finding out whether a specific string of characters is present in a set of characters. In this article, I will show you how to validate a specific character set using regular expressions in golang. First, to use regular expressions in golang, you need to import the regular expression package. In golang, the standard regular expression package is regexp. You can use the following code to import: import(&quo

Detailed explanation of character sets and collation rules in MySQL Detailed explanation of character sets and collation rules in MySQL Jun 14, 2023 pm 02:01 PM

MySQL is a widely used relational database management system. In order to support character sets and collation rules between different languages ​​and cultures, MySQL provides multiple character set and collation settings. Character set and collation are very important concepts in MySQL and play a vital role in the data storage and query process. Let's take a closer look at the character sets and collation rules in MySQL. 1. Character set The character set in MySQL determines how data is stored in the database. Common character sets include A

PHP returns the name of the character set PHP returns the name of the character set Mar 21, 2024 am 09:56 AM

This article will explain in detail the name of the character set returned by PHP. The editor thinks it is very practical, so I share it with you as a reference. I hope you can gain something after reading this article. 1. Character set in PHP The character set in PHP is used to represent a collection of letters, numbers and symbols used in text data. It defines how byte sequences are mapped to character values. PHP supports multiple character sets, including: ASCII: American Standard Code for Information Interchange, containing 7-bit characters and used in text-based systems. UTF-8: Universal Character Set Transformation Format - 8-bit, a variable-length character set widely used in modern systems. UTF-16: Universal Character Set Transformation Format - 16 bits, a fixed-length character set used to represent large numbers of characters

See all articles