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 the application of the four states of hyperconnection

Although you think it may be a browser problem, i...

Detailed explanation of the basic functions and usage of MySQL foreign keys

This article uses examples to illustrate the basi...

Install Python virtual environment in Ubuntu 18.04

For reference only for Python developers using Ub...

Linux nohup command principle and example analysis

nohup Command When using Unix/Linux, we usually w...

Linux operation and maintenance basic swap partition and lvm management tutorial

Table of contents 1. Swap partition SWAP 1.1 Crea...

Solve the problem that ifconfig and addr cannot see the IP address in Linux

1. Install the Linux system on the virtual machin...

HTML realizes real-time monitoring function of Hikvision camera

Recently the company has arranged to do some CCFA...

Detailed steps for Python script self-start and scheduled start under Linux

1. Python automatically runs at startup Suppose t...

mysql is not an internal command error solution

The error "mysql is not an internal command&...

Detailed explanation of building MySQL master-slave environment with Docker

Preface This article records how I use docker-com...

New usage of watch and watchEffect in Vue 3

Table of contents 1. New usage of watch 1.1. Watc...

How to use Nginx to proxy multiple application sites in Docker

Preface What is the role of an agent? - Multiple ...

Vue uses Baidu Maps to realize city positioning

This article shares the specific code of Vue usin...