MySQL二进制免编译安装

MySQL二进制免编译安装

1、下载MySQL包上传到/usr/local/src/下
[root@antong ~]# cd /usr/local/src/
[root@antong src]# ls
mysql-5.6.47-linux-glibc2.12-x86_64.tar.gz
2、解压并移动重命名
[root@antong src]# tar -zxvf mysql-5.6.47-linux-glibc2.12-x86_64.tar.gz 
[root@antong src]# mv mysql-5.6.47-linux-glibc2.12-x86_64 /usr/local/mysql
3、建立mysql用户
[root@antong src]# useradd -s /sbin/nologin -M mysql  //-s创建不能登录的用户,-M不创建家目录
4、初始化数据库
[root@antong src]# cd /usr/local/mysql/
[root@antong mysql]# mkdir -p /data/mysql;chown -R mysql:mysql /data/mysql
[root@antong mysql]# yum install -y perl-Module-Install.noarch    //安装依赖环境
[root@antong mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
[root@antong mysql]# echo $?
0
5、拷贝配置文件修改配置文件
[root@antong mysql]# cp support-files/my-default.cnf /etc/my.cnf
cp: overwrite ‘/etc/my.cnf’? y
[root@antong mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@antong mysql]# chmod 755 /etc/init.d/mysqld  //修改权限
[root@antong mysql]# vim /etc/my.cnf  //修改配置文件
basedir = /usr/local/mysql
datadir = /data/mysql
port = 3306
server_id = 10
socket = /tmp/mysql.sock
[root@antong mysql]# vim /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/data/mysql
6、把启动脚本加入到系统服务项
[root@antong mysql]# chkconfig --add mysqld [root@antong mysql]# chkconfig mysqld on [root@antong mysql]# service mysqld start
posted @ 2021-09-14 11:09  殇黯瞳  阅读(76)  评论(0编辑  收藏  举报