Ubuntu MySQL 5.6 version removal/installation/encoding configuration file configuration

Ubuntu MySQL 5.6 version removal/installation/encoding configuration file configuration

1. Remove 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 (very important)

Some of the above are actually redundant, it is recommended to execute them in order.

2. Clean up residual data

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

3. Install mysql

a. sudo apt-get install mysql-server
b. sudo apt-get install mysql-client
c. sudo apt-get install php5-mysql (installing php5-mysql is to connect php and mysql)

After installation, the MySQL service can be started. You can also manage the MySQL service with the following command

service mysql start (Start mysql) 
service mysql stop (Shut down mysql) 
service mysql restart (Restart mysql)

Use the following command to enter mysql

mysql -u root -p 123456 (123456 is the password you set for yourself)

View Encoding

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/ | 
+--------------------------+----------------------------+

You will find that some encodings are latin1, which will cause garbled Chinese characters. Modify the encoding configuration as follows

cd /etc/mysql/my.cnf (When modifying the code, pay attention to your own MySQL version and system, which may be different) 
sudo chmod 775 my.cnf 
sudo vim my.cnf

Add the following content after the file

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

ESC + :wq save and exit

Use service mysql restart to restart the mysql service

You may also be interested in:
  • Manually install mysql5.7.10 on Ubuntu
  • Ubuntu 16.04 mysql5.7.17 open remote port 3306
  • MySQL 5.7.17 installation and configuration tutorial under Linux (Ubuntu)
  • Solution to the error "libpng12-0 package not installed" when installing mysql workbench in Ubuntu 16.10
  • Python installation mysql-python concise notes (ubuntu environment)

<<:  How to upload the jar package to nexus via the web page

>>:  Vue uses Split to encapsulate the universal drag and slide partition panel component

Recommend

Detailed explanation of MySQL Strict Mode knowledge points

I. Strict Mode Explanation According to the restr...

Summary of the use of CSS scope (style splitting)

1. Use of CSS scope (style division) In Vue, make...

33 ice and snow fonts recommended for download (personal and commercial)

01 Winter Flakes (Individual only) 02 Snowtop Cap...

How to prevent users from copying web page content using pure CSS

Preface When I was typing my own personal blog, I...

What is Software 404 and 404 Error and what is the difference between them

First of all, what is 404 and soft 404? 404: Simpl...

Why should the number of rows in a single MySQL table not exceed 5 million?

Today, let’s discuss an interesting topic: How mu...

Solution to docker suddenly not being accessible from the external network

According to the methods of the masters, the caus...

The benefits and examples of placing the site map at the bottom of the web page

In the past, almost every website had a sitemap p...

HTML 5.1 learning: 14 new features and application examples

Preface As we all know, HTML5 belongs to the Worl...

Several ways to shut down Hyper-V service under Windows 10

When using VMware Workstation to open a virtual m...

MySQL compressed package version zip installation configuration method

There are some problems with the compressed versi...

An article to quickly understand Angular and Ionic life cycle and hook functions

Table of contents Angular accomplish Calling orde...

Code for aligning form checkbox and radio text

Alignment issues like type="radio" and t...