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

MySQL5.6 compilation, installation and configuration database tutorial

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

I don't know if you have any understanding of the articles similar to the MySQL5.6 compilation, installation and configuration database tutorials, but I'm here to tell you a little bit about it today. If you are interested, let's take a look at the body. I believe you will gain something after reading the MySQL5.6 compilation, installation and configuration database tutorial.

Compile and install:

Create MySQL dedicated accounts and user groups:

Groupaddmysql

Useradd-g mysql mysql

Set the resource limit of the user's operating system, add it at the end of / etc/security/limits.conf

Mysql soft nproc 2047

Mysql hardnproc 16384

Mysql soft nofile 1024

Mysql hardnofile 65536

Execute cmake. -LAH to view all supported parameters for MySQL compilation, or to view the official technical documentation through http://dev/mysql.com/doc/refman/5.6/en/source-configuration-options.html

Install cmake:

Yuminstall cmake

Problem: Generic Linux (Architecture Independent), Compressed TAR Archive

Solution: yum-y install ncurses-devel problem: CMAKE_C_COMPILER not set, after EnableLanguage solution: yum install gcc-c++

Rm-f CMakeCache.txt

Recompile installation

Decompress the source code package: tar-zvfx mysql-5.6.28.tar.gz

Go to the unzipped directory, perform cmake compilation and install:

Cdmysql-5.6.28

Cmake. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DDEFAULT_COLLATION=utf8_general_ci-DDEFAULT_CHARSET=utf8-DENABLED_LOCAL_INFILE=ON-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_FEDERATED_STORAGE_ENGINE=1-DWITH_BLACKHOLE_STORAGE_ENGINE=1-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1-DWITH_PARTITION_STORAGE_ENGINE=1-DWITH_PERFSCHEMA_STORAGE_ENGINE=1-DCOMPILATION_COMMENT='JSSfor mysqltest'-DWITH_READLINE=ON-DSYSCONFDIR=/data/mysqldata/3306-DMYSQL_UNIX_ADDR=/data/mysqldata/3306/mysql.sock

Make & & make install

Change the owner of the directory where the software resides to mysql:

Chown-R mysql:mysql / usr/local/mysql

Modify the mysql user environment variable and add it in / home/mysql/.bash_profile

# exportLANG=zh_CN.GB18030

ExportPATH=/usr/local/mysql/bin:$PATH

Manage MySQL database services

MySQL database service: general name of MySQL software, MySQL instance and MySQL database

MySQL instance: refers to the MySQL process and the memory resources held by the process

MySQL database: MySQLdata directory or MySQLdatabase file

Mysql database: mysql this DB

Mysql: mysql, a command line interactive tool for connecting to MySQL databases.

Create the default path for the database file:

Mkdir-p/data/mysqldata/ {3306 / {data,tmp,binlog}, backup,scripts}

Chown-R mysql:mysql / data/mysqldata

Chown-R mysql:mysql / usr/local/mysql

Add the MySQL configuration file / data/mysqldata/3306/my.cnf as follows:

[client]

Port = 3306

Socket = / data/mysqldata/3306/mysql.sock

# The MySQL server

[mysqld]

Port = 3306

User = mysql

Socket = / data/mysqldata/3306/mysql.sock

Pid-file = / data/mysqldata/3306/mysql.pid

Basedir = / usr/local/mysql

Datadir = / data/mysqldata/3306/data

Tmpdir = / data/mysqldata/3306/tmp

Open_files_limit = 10240

Explicit_defaults_for_timestamp

Sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

# Buffer

Max_allowed_packet = 256m

Max_heap_table_size = 256m

Net_buffer_length = 8K

Sort_buffer_size = 2m

Join_buffer_size = 4m

Read_buffer_size = 2m

Read_rnd_buffer_size = 16m

# Log

Log-bin = / data/mysqldata/3306/binlog/mysql-bin

Binlog_cache_size = 32m

Max_binlog_cache_size = 512m

Max_binlog_size = 512m

Binlog_format = mixed

Log_output = FILE

Log-error =.. / mysql-error.log

Slow_query_log = 1

Slow_query_log_file =.. / slow_query.log

General_log = 0

General_log_file =.. / general_query.log

Expire-logs-days = 14

# InnoDB

Innodb_data_file_path = ibdata1:2048M:autoextend

Innodb_log_file_size = 256m

Innodb_log_files_in_group = 3

Innodb_buffer_pool_size = 1024m

[mysql]

No-auto-rehash

Prompt = (\ u @\ h) [\ d]\ _

Default-character-set = gbk

Initialize the MySQL database:

/ usr/local/mysql/scripts/mysql_install_db--datadir=/data/mysqldata/3306/data-- basedir=/usr/local/mysql

Start the MySQL service:

$/ usr/local/mysql/bin/mysqld_safe--defaults-file=/data/mysqldata/3306/my.cnf &

Connect to the database:

$/ usr/local/mysql/bin/mysql

Check that the MySQL service is started:

Netstat-tnl | grep 3306

Keep a record that allows root users to connect locally, delete all other users:

Delete from mysql.user where (user,host) not in (select 'root','localhost')

Modify the administrator user:

Update mysql.user setuser='system',password=password ('password')

Truncate table mysql.db

Take effect all actions:

Flush privileges

MySQL service management configuration

Create intermediate definition files to improve the reusability of scripts:

$vi/data/mysqldata/scripts/mysql_env.ini

# set env

MYSQL_USER=system

MYSQL_PASS='password'

# check parameter

If [$#-ne 1]

Then

HOST_PORT=3306

Else

HOST_PORT=$1

Fi

Modify the permissions of the file at the operating system layer:

$chmod 600/data/mysqldata/scripts/mysql_env.ini

Create a mysql_db_startup.sh script to start the MySQL service:

$vi/data/mysqldata/scripts/mysql_db_startup.sh

#! / bin/sh

Source/data/mysqldata/scripts/mysql_env.ini

Echo "Stratup MySQL Service:local_" ${HOST_PORT}

/ usr/local/mysql/bin/mysqld_safe--defaults-file=/data/mysqldata/$ {HOST_PORT} / my.cnf &

Create a mysql_db_shutdown.sh script to shut down the MySQL service:

$vi / data/mysqldata/scripts/mysql_db_shutdown.sh

#! / bin/sh

Source/data/mysqldata/scripts/mysql_env.ini

Echo "Shutdown MySQL Service:localhost_" ${HOST_PORT}

/ usr/local/mysqldata/bin/mysqladmin-u$ {MYSQL_USER}-p$ {MYSQL_PASS}-S / data/mysqldata/$ {HOST_PORT} / mysql.sockshutdown

Create a mysqlplus.sh script file for quick login:

$vi/data/mysqldata/scripts/mysqlplus.sh

#! / bin/sh

Source/data/mysqldata/scripts/mysql_env.ini

Echo "Login MySQL Service:localhost_" ${HOST_PORT}

/ usr/local/mysql/bin/mysql-u$ {MYSQL_USER}-p$ {MYSQL_PASS}-S / data/mysqldata/$ {HOST_PORT} / mysql.sock $2

Authorize the above script execution permissions:

$chmod + x / data/mysqldata/scripts/*.sh

Edit the environment variable of the mysql user to add the above path to the PATH:

$echo "exportPATH=/data/mysqldata/scripts:$PATH" > > ~ / .bash_profile

$source ~ / .bash_profile

Edit / etc/rc.local to boot MySQL and add at the end:

Sudo-I-u mysql/data/mysqldata/scripts/mysql_db_startupsh 3306 > / home/mysql/mysql_db_startup.log 2 > & 1

Visudo comments out Defaultsrequiretty to avoid sudo: sorry,you myst have a ttyto run sudo

What do you think of this article after reading the tutorial on MySQL5.6 compilation, installation and configuration of database? If you want to know more about it, you can continue to follow our industry information section.

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