Mysql installation and configuration summary, Mysql installation and configuration Summary

Source: Internet
Author: User

Mysql installation and configuration summary, Mysql installation and configuration Summary

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Mysql installation and configuration summary:

For Mysql database information, we will not describe it here. If you need it, you can refer to the relevant information. In addition, this article summarizes the theme of Mysql installation, configuration and service operations.

 

· Installation

· Configuration

· Operation

· Problems

 

I. Installation

The installation methods for different systems are slightly different. Here is the installation on Mac OSX, so you can use homebrew for installation. For the installation methods for Linux, see:

Http://www.cnblogs.com/quanzhiguo/p/7520651.html

 

$ Brew install mysql

 

NOTE:

Online download and installation, the advantage is that the installed software is relatively new, the bad thing is that when the network is slow, the download is slow.

 

Ii. Configuration

1. my. cnf File

To avoid overwriting my. cnf file. We recommend that you move the file to/etc/. The default location is/usr/local/Cellar/mysql/5.7.11/my. cnf:

$ Sudo mv/usr/local/Cellar/mysql/5.7.11/my. cnf/etc/

 

2. Configure my. cnf

The following figure shows the optimized configuration of the my. cnf configuration file:

[Mysqld]

Port = 3306

Server_id = 1

Character-set-server = utf8

Default-storage-engine = INNODB

Socket =/tmp/mysql. sock

Skip-external-locking

 

Key_buffer = 16 K

Query_cache_limit = 256 K

Query_cache_size = 4 M

Max_allowed_packet = 1 M

Table_open_cache = 128 # Number of table caches, usually a multiple of max_connections

 

Max_connections = 32

Thread_concurrency = 2

 

Sort_buffer_size = 64 K

Read_buffer_size = 256 K

Read_rnd_buffer_size = 256 K

Net_buffer_length = 2 K

Thread_stack = 64 K

 

SQL _mode = NO_ENGINE_SUBSTITUTION, STRICT_TRANS_TABLES

 

[Mysqldump]

Quick

Max_allowed_packet = 16 M

 

[Mysql]

No-auto-rehash

Default-character-set = utf8

 

[Isamchk]

Key_buffer = 8 M

Sort_buffer_size = 8 M

 

[Myisamchk]

Key_buffer = 8 M

Sort_buffer_size = 8 M

 

[Mysqlhotcopy]

Interactive-timeout

 

Iii. Operations

For Mysql service operations, it is mainly [start | stop | restart]. To simplify the operation, modify the/etc/profile file and add the following content:

Alias mysqlstart = "/usr/local/opt/mysql/bin/mysql. server start"

Alias mysqlstop = "/usr/local/opt/mysql/bin/mysql. server stop"

Alias mysqlrestart = "/usr/local/opt/mysql/bin/mysql. serverrestart"

 

$ Source/etc/profile # To make the profile take effect immediately, you can directly:

 

$ Mysqlstart // start the service

$ Mysqlstop // stop the service

$ Mysqlrestart // restart the service

 

The details are as follows:

 

 

 

Iv. Problems

1. Mysql Service Startup Error

Problems:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql. sock' (2)

 

Problem:

The problem occurs because mysql is installed repeatedly (mysql 5.7 is the latest.

Compared with the previous version, Mysql 5.7 has made some adjustments, so the best solution is to back up the original database data and reinitialize a new instance.

 

Solution:

$ Mysqld -- defaults-file =/etc/my. cnf -- user = mysql -- datadir =/var/mysql/data -- initialize-insecure

 

NOTE:

After Mysql 5.7, mysqld needs to be used for initialization. Before Mysql 5.6 and, mysql_install_db is used;

-- Defaults-file: Specifies the my. cnf global configuration file;

-- Datadir: Specifies the data installation directory. Ensure that the data directory is empty and has the write permission;

-- Initialize-insecure: If this command is added, a root @ localhost account with an empty password will be created; otherwise, a root @ localhost account with a non-empty password will be generated, in addition, the password is stored in the log file (in version 5.6, it is stored in ~ /. Mysql_secret file );

 

PS:

There are many reasons for the above error, such:

A. the configuration file my. cnf has an error.

B. multiple occurrences of my. cnf, resulting in coverage problems

For more information, see Error Log Analysis and tracking.

 

2. To be updated...

Related Article

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.