Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to download, install, configure and encode mysql

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

Editor to share with you how to download installation configuration and coding settings of mysql. I hope you will get something after reading this article. Let's discuss it together.

Download mysql

The easiest way is to enter the command directly: sudo apt-get install mysql-server. After installation, the environment variables have been configured automatically, so you can use the command of mysql directly.

Download and install process will prompt for a user name and password, very easy!

Note: it is recommended to change the cn in / etc/apt/source.list to us. The servers in the United States are much faster than those in China.

2. Configure mysql

1. Start mysql

2. In mydql >, enter: show variables like 'character%'; to view the code

+-+

| | Variable_name | Value |

+-+

| | character_set_client | latin1 |

| | character_set_connection | latin1 |

| | character_set_database | latin1 |

| | character_set_results | latin1 |

| | character_set_server | latin1 |

| | character_set_system | utf8 |

| | character_sets_dir | / usr/share/mysql/charsets/ |

+-+

3. Set it to utf8mb4 code (multi-use secondary code in production)

Console command: locate my.cnf to find mysql configuration file: my.cnf

B. Edit the my.cnf file as follows (red for my change):

[client]

Port = 3306

Socket = / var/run/mysqld/mysqld.sock

Default-character-set = utf8mb4

# Here is entries for some specific programs

# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.

[mysqld_safe]

Socket = / var/run/mysqld/mysqld.sock

Nice = 0

[mysqld]

Character-set-client-handshake = FALSE

Character-set-server = utf8mb4

Collation-server = utf8mb4_unicode_ci

#

# * Basic Settings

#

User = mysql

Pid-file = / var/run/mysqld/mysqld.pid

Socket = / var/run/mysqld/mysqld.sock

Port = 3306

Basedir = / usr

Datadir = / var/lib/mysql

Tmpdir = / tmp

Lc-messages-dir = / usr/share/mysql

Skip-external-locking

#

# Instead of skip-networking the default is now to listen only on

# localhost which is more compatible and is not less secure.

Bind-address = 0.0.0.0

"/ etc/mysql/my.cnf" [readonly] 132L, 3675C

4. Restart mysql (very important)

5. Test configuration

Enter: show variables like 'character%'; in mydql > to view the code as follows:

+-+

| | Variable_name | Value |

+-+

| | character_set_client | utf8mb4 |

| | character_set_connection | utf8mb4 |

| | character_set_database | utf8mb4 |

| | character_set_filesystem | binary |

| | character_set_results | utf8mb4 |

| | character_set_server | utf8mb4 |

| | character_set_system | utf8 |

| | character_sets_dir | / usr/share/mysql/charsets/ |

+-+

4. Modify the Xshell code

1. Modify the connection code

Select the session to be connected in xshell = > right-click "Properties" = > Category Select "Terminal" = > Encoding drop-down select "unicodeutf-8" = > OK

2. Modify the "Code" button on the Xshell toolbar and select "utf8".

5. Modify ubuntu code

1. To view the server code, enter locale on the command line

LANG=zh_CN.UTF-8

LANGUAGE=zh_CN:zh

LC_CTYPE= "zh_CN.UTF-8"

LC_NUMERIC=zh_CN

LC_TIME=zh_CN

LC_COLLATE= "zh_CN.UTF-8"

LC_MONETARY=zh_CN

LC_MESSAGES= "zh_CN.UTF-8"

LC_PAPER=zh_CN

LC_NAME=zh_CN

LC_ADDRESS=zh_CN

LC_TELEPHONE=zh_CN

LC_MEASUREMENT=zh_CN

LC_IDENTIFICATION=zh_CN

LC_ALL=

2. Modify the server code

A. Use administrator privileges to enter / etc/default/

B. Edit the file using vi: locale is as follows:

LANG= "en_US.UTF-8"

LANGUAGE= "en_US:"

~

~

3. Restart the server (virtual machine)

4. Check the server code again. Enter locale on the command line.

LANG=en_US.UTF-8

LANGUAGE=en_US:

LC_CTYPE= "en_US.UTF-8"

LC_NUMERIC= "en_US.UTF-8"

LC_TIME= "en_US.UTF-8"

LC_COLLATE= "en_US.UTF-8"

LC_MONETARY= "en_US.UTF-8"

LC_MESSAGES= "en_US.UTF-8"

LC_PAPER= "en_US.UTF-8"

LC_NAME= "en_US.UTF-8"

LC_ADDRESS= "en_US.UTF-8"

LC_TELEPHONE= "en_US.UTF-8"

LC_MEASUREMENT= "en_US.UTF-8"

LC_IDENTIFICATION= "en_US.UTF-8"

LC_ALL=

All set to utf-8 successful.

Through the above five settings, all the codes are set to unified utf8, you can enter Chinese in Xshell, you can also enter Chinese in mysql, all done!

After reading this article, I believe you have a certain understanding of "how to download installation configuration and coding settings for mysql". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report