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!

 至此数据库安装成功。

相关文章
相关标签/搜索