centos 6.10源碼安裝mysql5.5.62實驗

查看系統版本mysql

[root@ABC ~]# cat /etc/redhat-releaselinux

CentOS release 6.10 (Final)c++

下載mysql5.5.62源碼包,解壓後安裝git

tar –zxf mysql-5.5.62.tar.gz  -C /usr/local/srcsql

根據提示安裝必要的依賴庫文件數據庫

yum install -y gcc gcc-c++ ncurses-devel git cmakevim

預編譯規劃

Mysql軟件安裝目錄/usr/local/mysql;mysql數據目錄爲/usr/local/mysql/data;安全

Mysql錯誤日誌文件保存目錄爲/var/log/mysql/error.log,建立相應目錄和用戶並賦權bash

groupadd mysql&&useradd –r –g mysql –s /sbin/falsessh

mkdir –p /usr/local/mysql/data&&chown –R mysql:mysql /usr/local/mysql

mkdir /var/log/mysql&&chown –R mysql:mysql /var/log/mysql

進入解壓包目錄,使用cmake預編譯

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data/ -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1

編譯安裝

make –j 4&& make install –j 4

進入安裝目錄執行操做

cd /usr/local/mysql

拷貝mysql服務腳本文件到系統目錄

cp support-files/mysql.server /ect/init.d/mysqld

設置mysqld服務爲開機自啓動

chkconfig - -level  3  mysqld  on

chkconfig - -list mysqld

啓動mysql服務

service mysqld start

啓動報錯,沒法正常啓動

安裝完5.5.62的mysql後,必須要先執行mysql_install_db才能執行後續操做

[root@ABC mysql]#/usr/local/mysql/ scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

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

/usr/local/mysql/bin/mysqladmin -u root -h 主機名 password 'new-password'

Alternatively you can run:

/usr/local/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test

databases and anonymous user created by default.  This is

strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

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

You can test the MySQL daemon with mysql-test-run.pl

 

啓動mysql服務

[root@ABC mysql]# service mysqld start

Starting MySQL SUCCESS!

修改環境變量,將mysql命令添加到系統中

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

要想使命令永久生效,須要將該命令添加到$HOME/.bashrc_profile文件末尾便可,

使用source $HOME/.bashrc_profile 讓命令生效

 

安全初始化mysql

[root@ABC ~]# mysql_secure_installation

 

登錄mysql

[root@ABC ~]# mysql –u root –p password

查看端口和狀態

[root@ABC mysql]# netstat -ntulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 23441/mysqld
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2195/sshd
tcp 0 0 :::80 :::* LISTEN 1744/httpd
tcp 0 0 :::22 :::* LISTEN 2195/sshd
udp 0 0 0.0.0.0:68 0.0.0.0:* 1231/dhclient
[root@ABC mysql]# ps -ef | grep mysql
root 23145 1991 0 18:34 pts/0 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe
mysql 23441 23145 0 18:34 pts/0 00:00:01 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/var/log/mysql/error.log --pid-file=ABC.pid --socket=/usr/local/mysql/mysql.sock --port=3306
root 23872 1991 0 19:36 pts/0 00:00:00 grep mysql

 重啓測試

[root@b mysql]# service mysqld restart

ERROR! MySQL server PID file could not be found!

沒法啓動,提示server PID沒法找到關閉selinux防火牆並重啓測試

[root@b mysql]# vim /etc/selinux/config
[root@b mysql]# reboot

[root@ABC ~]# service mysqld restart

Shutting down MySQL. SUCCESS!
Starting MySQL.. SUCCESS!

 至此數據庫安裝成功。

相關文章
相關標籤/搜索