Uninstalling, reinstalling, and encoding MySQL in Ubuntu

Source: Internet
Author: User
Recently, MySQL in Ubuntu has encountered some problems. I have not found the answer for a long time on the Internet, so I uninstalled and reinstalled it. Of course, as the title is written, encoding is also involved here. When the original installation was uninstalled, sudoapt-getinstallmysql-servermysql-client was used. Therefore, the corresponding uninstallation should be: sudoaptitudepurgemysq.

Recently, MySQL in Ubuntu has encountered some problems. I have not found the answer for a long time on the Internet, so I uninstalled and reinstalled it. Of course, as the title is written, encoding is also involved here. When the original installation was uninstalled, sudo apt-get install mysql-server mysql-client was used. Therefore, the corresponding uninstallation should be: sudo aptitude purge mysq.

Recently, MySQL in Ubuntu has encountered some problems. I have not found the answer for a long time on the Internet, so I uninstalled and reinstalled it. Of course, as the title is written, encoding is also involved here.

Uninstall

At the beginning, the following commands were used:

sudo apt-get install mysql-server mysql-client

Therefore, the corresponding uninstallation should be:

sudo aptitude purge mysql-server mysql-client

In fact, I also tried to uninstall the new software manager, but I was skipped the step of setting the root password when I installed it again. Should it be incomplete? However, in any case, I use the following command to uninstall it and reinstall it normally.

Install MySQL
sudo apt-get install mysql-server mysql-client

Yes, it is still the original installation method. You need to enter the root password and confirm it once. However, after I install sudo/etc/init. d/mysql restart cannot be used to restart, start, and stop sudo/etc/init. d/mysql restart. The following prompt appears:

luo@luo-ubuntu:~$ sudo /etc/init.d/mysql restartRather than invoking init scripts through /etc/init.d, use the service(8)utility, e.g. service mysql restartSince the script you are attempting to invoke has been converted to anUpstart job, you may also use the restart(8) utility, e.g. restart mysqlmysql start/running, process 3942luo@luo-ubuntu:~$ sudo /etc/init.d/mysql restartRather than invoking init scripts through /etc/init.d, use the service(8)utility, e.g. service mysql restartSince the script you are attempting to invoke has been converted to anUpstart job, you may also use the restart(8) utility, e.g. restart mysqlmysql start/running, process 3942

Therefore, follow the prompts to use the following command line to restart, start, and stop Mysql:

sudo restart mysqlsudo start mysqlsudo stop mysql
Encoding

It has been circulated on the Internet that the default encoding of Mysql is latin1, And I used Mysql as well, but after I reinstall it, I went to Mysql to use: show variables like "character_set %". The results are as follows:

mysql> show variables like 'character%';+--------------------------+----------------------------+| Variable_name | Value |+--------------------------+----------------------------+| character_set_client | utf8 || character_set_connection | utf8 || character_set_database | utf8 || character_set_filesystem | binary || character_set_results | utf8 || character_set_server | utf8 || character_set_system | utf8 || character_sets_dir | /usr/share/mysql/charsets/ |+--------------------------+----------------------------+8 rows in set (0.00 sec)

Is this the new version? I am not sure, so I should record the method for modifying Mysql encoding.

First, go to Mysql and use show variables like 'character % '; to check whether the encoding is displayed:

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

To modify the encoding, modify the/etc/mysql/my. cnf file:

Find the client configuration [client] and add it below

Default-character-set = utf8 default character set: utf8

Add in [mysqld]

default-character-set=utf8init_connect='SET NAMES utf8'

After modification, restart mysql and query show variables like 'character % '.

If not, OK.

Original article address: uninstalling, reinstalling, and encoding MySQL In Ubuntu. Thank you for sharing with me.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.