MySQL-related settings under Linux

Source: Internet
Author: User

After installing MySQL under Linux, it is often necessary to make the following changes to use it more easily

1. Add a remote connection user

Usually we need to remotely connect MySQL database from outside, MySQL database default is not set to allow remote connection of users, we need to add it ourselves.

You can first view the existing users in the current MySQL database:

Use MySQL;

Select Host,user,password from user;

In the results above, host indicates that the user is allowed to connect to the database, the user represents the username, and password represents the password

To add a new user:

GRANT all privileges on * * to ' remotes ' @ '% ' identified by ' PWD ';

Remote is the user name of the new user;% means that the user is allowed to connect from any host, or it can be specified as the IP of a machine; PWD is the password of the new user;

If you are still unable to connect through the remote, you need to comment out the bind-address line in/ETC/MYSQL/MY.CNF

2. Set default encoding is UTF-8

MySQL's default encoding is not utf-8, we need to set the default encoding to Utf-8, so as to avoid the development process encountered a lot of garbled problems

The current encoding can be viewed first

Show variables like '%character% ';

Modify the Encoding

Open/ETC/MYSQL/MY.CNF

Add Default-character-set=utf-8//Set client-side encoding in [client], which is the encoding of statements sent by the client to the server

Add Default-characterr-set=utf-8//Set server-side encoding in [mysqld] to set the encoding for server-saved data

Note: In later versions of version 5.0, the Default-character-set field is not supported in mysqld and will cause MySQL to fail to restart if added. Need to be changed into Character-set-server=utf8

The above modifications are not valid for existing databases and tables, only for future changes.

MySQL-related settings under Linux

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.