日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql源码安装配置_MySQL源码安装及配置

發布時間:2024/8/5 数据库 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql源码安装配置_MySQL源码安装及配置 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

目錄

--cmake下載安裝

http://cmake.org/download/

# wgethttp://cmake.org/files/v3.3/cmake-3.3.2.tar.gz

# tar xzvf cmake-3.3.2.tar.gz

# cd cmake-3.3.2

# ./configure

# gmake && make install

--創建用戶

# groupadd mysql

# useradd -g mysql mysql

--設置用戶操作系統資源限制

# vi /etc/security/limits.conf

mysql?? soft???nproc?? 2047

mysql?? hard???nproc?? 16384

mysql?? soft???nofile? 1024

mysql?? hard???nofile? 65536

--下載并解壓縮MySQL源碼文件

https://dev.mysql.com/downloads/mysql/

# tar xzvf mysql-5.6.26.tar.gz

# cd mysql-5.6.26

--執行cmake生成編譯配置文件

cmake .-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci\

-DINABLED_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='JSS formysqltest' \

-DWITH_READLINE=ON \

-DSYSCONFDIR=/data/mysqldata/3306\

-DMYSQL_UNIX_ADDR=/data/mysqldata/3306/mysql.lock

--編譯并安裝

# make && make install

--修改目錄權限

# chown -R mysql:mysql/usr/local/mysql

--修改環境變量文件

# vi /home/mysql/.bash_profile

export LANG=zh_CN.GB18030

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

2.安裝過程中遇到的問題:

問題1

在執行cmake編譯時出現了下面的錯誤。

用cmake . -LH 命令可重現問題

[root@host9 mysql-5.6.26]#cmake . -LH

-- Running cmake version 3.3.2

-- MySQL 5.6.26

-- Packaging as:mysql-5.6.26-Linux-x86_64

-- HAVE_VISIBILITY_HIDDEN

-- HAVE_VISIBILITY_HIDDEN

-- HAVE_VISIBILITY_HIDDEN

-- Could NOT find Curses(missing:? CURSES_LIBRARYCURSES_INCLUDE_PATH)

CMake Error atcmake/readline.cmake:85 (MESSAGE):

Curses library not found.? Please install appropriate package,

remove CMakeCache.txt and rerun cmake.OnDebian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it isncurses-devel.

Call Stack (most recent callfirst):

cmake/readline.cmake:128 (FIND_CURSES)

cmake/readline.cmake:202(MYSQL_USE_BUNDLED_EDITLINE)

CMakeLists.txt:409 (MYSQL_CHECK_EDITLINE)

-- Configuring incomplete,errors occurred!

See also"/root/mysql-5.6.26/CMakeFiles/CMakeOutput.log".

See also"/root/mysql-5.6.26/CMakeFiles/CMakeError.log".

解決方法:安裝ncurses-devel包

# yum installncurses-devel.x86_64

# make clean

# rm -rf CMakeCache.txt

# cmake . -LH

參考:

3.創建MySQL服務

--創建數據目錄

# mkdir /data

# cd /data

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

# chown -R mysql:mysqlmysqldata

# su - mysql

$cd /usr/local/mysql

--創建參數文件

$touch/data/mysqldata/3306/my.cnf

$vi /data/mysqldata/3306/my.cnf

[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??? = ibdatal: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

--初始化數據庫

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

Installing MySQL systemtables...2015-09-25 16:19:57 0 [Note] /usr/local/mysql/bin/mysqld (mysqld5.6.26-log) starting as process 30402 ...

OK

Filling helptables...2015-09-25 16:20:01 0 [Note] /usr/local/mysql/bin/mysqld (mysqld5.6.26-log) starting as process 30425 ...

OK

To start mysqld at boot timeyou have to copy

support-files/mysql.server tothe right place for your system

PLEASE REMEMBER TO SET APASSWORD FOR THE MySQL root USER !

To do so, start the server,then issue the following commands:

/usr/local/mysql/bin/mysqladmin -u rootpassword 'new-password'

/usr/local/mysql/bin/mysqladmin -u root -hhost9.localdomain password 'new-password'

Alternatively you can run:

/usr/local/mysql/bin/mysql_secure_installation

which will also give you theoption of removing the test

databases and anonymous usercreated by default.? This is

strongly recommended forproduction servers.

See the manual for moreinstructions.

You can start the MySQL daemonwith:

cd . ; /usr/local/mysql/bin/mysqld_safe &

You can test the MySQL daemonwith mysql-test-run.pl

cd mysql-test ; perl mysql-test-run.pl

Please report any problems athttp://bugs.mysql.com/

The latest information aboutMySQL is available on the web at

http://www.mysql.com

Support MySQL by buyingsupport/licenses at http://shop.mysql.com

WARNING: Found existing configfile /usr/local/mysql/my.cnf on the system.

Because this file might be inuse, it was not replaced,

but was used in bootstrap(unless you used --defaults-file)

and when you later start theserver.

The new default config file wascreated as /usr/local/mysql/my-new.cnf,

please compare it with yourfile and take the changes you need.

--啟動數據庫服務

$mysqld_safe --defaults-file=/data/mysqldata/3306/my.cnf &

[1] 31069

[mysql@host9support-files]$150925 16:32:00 mysqld_safe Logging to '/data/mysqldata/3306/data/../mysql-error.log'.

150925 16:32:00 mysqld_safeStarting mysqld daemon with databases from /data/mysqldata/3306/data

--查看數據庫進程

[mysql@host9 support-files]$netstat -lnt|grep 3306

tcp??????? 0?????0 :::3306???????????????????? :::*??????????????????????? LISTEN

$ps -ef | grep bin/mysql | grep -v grep

mysql??? 31069 29398?0 16:31 pts/0??? 00:00:00 /bin/sh/usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysqldata/3306/my.cnf

mysql??? 31535 31069?0 16:32 pts/0??? 00:00:00/usr/local/mysql/bin/mysqld --defaults-file=/data/mysqldata/3306/my.cnf--basedir=/usr/local/mysql --datadir=/data/mysqldata/3306/data--plugin-dir=/usr/local/mysql/lib/plugin--log-error=/data/mysqldata/3306/data/../mysql-error.log --open-files-limit=10240--pid-file=/data/mysqldata/3306/mysql.pid--socket=/data/mysqldata/3306/mysql.sock --port=3306

4.創建管理腳本

--創建中間定義文件

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

--增加如下內容

# set env

MYSQL_USER=system

MYSQL_PASS='system'

# check parameter

if [ $# -ne 1 ]

then

HOST_PORT=3306

else

HOST_PORT=$1

fi

--修改權限

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

--創建啟動MySQL服務腳本

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

--增加如下內容

#!/bin/sh

source/data/mysqldata/scripts/mysql_env.ini

echo "Startup MySQLService: localhost_"${HOST_PORT}

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

--創建關閉MySQL服務腳本

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

--增加如下內容

#!/bin/sh

source/data/mysqldata/scripts/mysql_env.ini

echo "Shutdown MySQLService: localhost_"${HOST_PORT}

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

--創建快速登錄腳本

$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

--授予腳本權限

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

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

$ source ~/.bash_profile

--測試登錄MySQL

$ mysqlplus.sh

5.設置開機自動啟動

--修改/etc/rc.local,增加內容如下

# vi /etc/rc.local

sudo -i -u mysql/data/mysqldata/scripts/mysql_db_startup.sh 3306 >/home/mysql/mysql_db_startup.log 2>&1

總結

以上是生活随笔為你收集整理的mysql源码安装配置_MySQL源码安装及配置的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。