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

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql5.5编译安装脚本_mysql5.5 免编译安装及脚本启动报错深入

發(fā)布時間:2025/3/12 数据库 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql5.5编译安装脚本_mysql5.5 免编译安装及脚本启动报错深入 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

Mysql安裝環(huán)境簡介:

最近在做MHA。已經(jīng)安裝完畢heartbeat和drbd,現(xiàn)在準備安裝Mysql。

Mysql安裝目錄:/opt/mysql

Mysql數(shù)據(jù)目錄:/data/mysql

備注:/data目錄實際是drbd需要同步到備節(jié)點的磁盤分區(qū)

[root@mysql1 src]# df -h

Filesystem?????Size? Used Avail Use% Mounted on

/dev/sda2??????9.5G? 2.0G? 7.1G?22% /

tmpfs??????????932M???? 0? 932M??0% /dev/shm

/dev/sda1??????190M?? 58M? 123M?32% /boot

/dev/drbd0?????? 19G?832M?? 17G?? 5% /data

一、Mysql免編譯安裝(大家可以直接復(fù)制在命令行執(zhí)行或保存至shell腳本)

#1、解壓配置

yum install -y libaio-devel

cd /usr/local/src

[ ! -f mysql-5.5.49-linux2.6-x86_64.tar.gz] && \

wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.49-linux2.6-x86_64.tar.gz

tar zxf mysql-5.5.49-linux2.6-x86_64.tar.gz

mkdir /opt/

mv?mysql-5.5.49-linux2.6-x86_64/opt/mysql-5.5.49

ln -s /opt/mysql-5.5.49 ?/opt/mysql

#2、創(chuàng)建用戶

if ! id mysql;then

useradd mysql -s /sbin/nologin -M

fi

#可以減寫:! id mysql && useradd mysql -s /sbin/nologin -M ####

#還有一種***子放屁的做法。

#groupadd mysql

#useradd -g mysql-M mysql

#用useradd mysql時就會創(chuàng)建mysql組,搞不懂為什么還先添加組

#3、初始化數(shù)據(jù)庫,單實例啟動

/opt/mysql/scripts/mysql_install_db --datadir=/data/mysql --basedir=/opt/mysql --user=mysql

cp /etc/my.cnf ?/etc/my.cnf.ori

grep -Ev "#|^$" /opt/mysql/support-files/my-innodb-heavy-4G.cnf? > /etc/my.cnf

cp /opt/mysql/support-files/mysql.server /etc/init.d/mysqld

chkconfig mysqld on

#chmod +x /etc/init.d/mysqld (默認已有x權(quán)限)

#4、添加環(huán)境變量

echo "PATH=/opt/mysql/bin:$PATH" >> /etc/profile

. /etc/profile

#4、修改/etc/my.cnf或/etc/init.d/mysqld (暫時不修改,讓腳本啟動報錯)

basedir=/opt/mysql

datadir=/data/mysql

***************************************************************************************

1、安裝錯誤

[root@mysql1 src]#/opt/mysql/scripts/mysql_install_db --datadir=/data/mysql --basedir=/opt/mysql--user=mysql

Installing MySQL system tables...

/opt/mysql/bin/mysqld: errorwhile loading shared libraries: libaio.so.1: cannot open shared object file: Nosuch file or directory

解決:yum install -y libaio-devel

2、啟動報錯1:沒指定basedir和datadir

[root@mysql1 src]#service mysqld start

/etc/init.d/mysqld: line 256: my_print_defaults: command notfound

/etc/init.d/mysqld: line 276: cd: /usr/local/mysql: No suchfile or directory

Starting MySQL ERROR!Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)

3、啟動報錯2

如果指定了basedir=/opt/mysql,但datadir=? 為空時,啟動會報錯。

[root@mysql1 src]#service mysqld restart

ERROR! MySQL server PID file could not befound!

Starting MySQL.ERROR! The server quit without updating PID file (/opt/mysql/data/mysql1.pid).

[root@mysql1 src]#vi /etc/init.d/mysqld

4、啟動報錯3

也是basedir和datadir都沒指定

[root@mysql1 src]#service mysqld restart

/etc/init.d/mysqld:line 256: my_print_defaults: command not found

/etc/init.d/mysqld:line 256: my_print_defaults: command not found

ERROR! MySQL server PID file could not befound!

/etc/init.d/mysqld:line 256: my_print_defaults: command not found

/etc/init.d/mysqld:line 276: cd: /usr/local/mysql: No such file or directory

Starting MySQLERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)

***********************************************************************************

前幾天解決了生產(chǎn)環(huán)境的腳本報錯的問題,現(xiàn)把報錯原理分析總結(jié)下:

請看下面/etc/init.d/mysqld的啟動腳本加粗部分解釋。

# If you install MySQL on some other placesthan /usr/local/mysql, then you

# have to do one of the following things for thisscript to work:

#

# - Run thisscript from within the MySQL installation directory

# - Create a/etc/my.cnf file with the following information:

#? [mysqld]

#? basedir=

# - Add the aboveto any other configuration file (for example ~/.my.ini)

#?? and copy my_print_defaults to /usr/bin

# - Add the pathto the mysql-installation-directory to the basedir variable

#?? below.

#

# If you want toaffect other MySQL variables, you should make your changes

# in the/etc/my.cnf, ~/.my.cnf or other MySQL configuration files.

# If you changebase dir, you must also change datadir. These may get

# If you changebase dir, you must also change datadir. These may get

# overwritten bysettings in the MySQL configuration files.

basedir=

datadir=

# Default value,in seconds, afterwhich the script should timeout waiting

# for serverstart.

# Value here isoverriden by value in my.cnf.

# 0 means don'twait at all

# Negative numbersmean to wait indefinitely

service_startup_timeout=900

# Lock directoryfor RedHat / SuSE.

lockdir='/var/lock/subsys'

lock_file_path="$lockdir/mysql"

# The followingvariables are only set for letting mysql.server find things.

# Set somedefaults

mysqld_pid_file_path=

if test -z "$basedir"

then

basedir=/usr/local/mysql

bindir=/usr/local/mysql/bin

if test -z"$datadir"

then

datadir=/usr/local/mysql/data

fi

sbindir=/usr/local/mysql/bin

libexecdir=/usr/local/mysql/bin

else

bindir="$basedir/bin"

if test -z"$datadir"

else

bindir="$basedir/bin"

if test -z"$datadir"

then

datadir="$basedir/data"

fi

sbindir="$basedir/sbin"

libexecdir="$basedir/libexec"

fi

翻譯:

1、如果basedir沒有指定mysql安裝路徑,啟動腳本就會以/usr/local/mysql做為安裝路徑啟動。所以mysql沒有安裝在/usr/local下,啟動必失敗

2、如果basedir=/opt/mysql指定了mysql安裝路徑,并且mysql安裝的路徑是在/opt/mysql情況下。但datadir= 為空時,啟動腳本會將$basedir/data(即/opt/mysql/data)做為mysql的數(shù)據(jù)目錄。平時我們習(xí)慣將data目錄放在/data/mysql下。此時啟動會報錯:

Starting MySQL. ERROR! The server quit without updatingPID file (/opt/mysql/data/mysql1.pid).

3、總結(jié):用/etc/init.d/mysql啟動時,最好在/etc/init.d/mysqld里設(shè)置basedir和datadir的值。或者在/etc/my.cnf 里[mysqld]下添加

[mysqld]

#port?????????? = 3306

socket????????? = /tmp/mysql.sock

basedir=/opt/mysql

datadir=/data/mysql

不知道有沒說明白。 建議大家再看看mysql啟動腳本的文件。

心得:最近mysql遇到不少問題,慶幸大部分出錯都能通過日志在百度上搜索出來。說明mysql使用的火熱程度及大家的分享精神

總結(jié)

以上是生活随笔為你收集整理的mysql5.5编译安装脚本_mysql5.5 免编译安装及脚本启动报错深入的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。