二进制安装mysql
Posted 只许澎湃不许爱
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了二进制安装mysql相关的知识,希望对你有一定的参考价值。
1.创建安装目录:
[[email protected] ~]# mkdir /application
2.下载二进制安装包:
wget https://downloads.mysql.com/archives/get/file/mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz
3.解压二进制包:
[[email protected] ~]# tar xf mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz
4.移动解压目录
[[email protected] ~]# mv mysql-5.6.40-linux-glibc2.12-x86_64 /application/mysql-5.6.40
5.做MySQL软连接
[[email protected] scripts]# ln -s /application/mysql-5.6.40/ /application/mysql
6.创建MySQL用户
[[email protected] ~]# useradd mysql -s /sbin/nologin -M
7.进入配置文件及启动脚本目录
[[email protected] ~]# cd /application/mysql-5.6.40/support-files
8.拷贝配置文件到/etc/my.cnf
[[email protected] support-files]# cp my-default.cnf /etc/my.cnf
9.拷贝启动脚本
[[email protected] support-files]# cp mysql.server /etc/init.d/mysqld
10.初始化MySQL
[[email protected] scripts]# cd /application/mysql-5.6.40/scripts
[[email protected] scripts]# ./mysql_install_db --user=mysql --basedir=/application/mysql --datadir=/application/mysql/data
--user 指定mysql用户
--basedir 指定mysql安装目录
--datadir 指定mysql数据目录
11.修改MySQL启动脚本及启动程序
[[email protected] scripts]# sed -i ‘s#/usr/local#/application#g‘ /etc/init.d/mysql /application/mysql/bin/mysqld_safe
12.启动MySQL
[[email protected] scripts]# /etc/init.d/mysqld start
13.添加环境变量
[[email protected] scripts]# echo ‘export PATH="/application/mysql/bin:$PATH"‘ > /etc/profile.d/mysql.sh
14.加载环境变量
[[email protected] scripts]# source /etc/profile
15.添加systemd启动
[[email protected] scripts]# vim /etc/systemd/system/mysqld.service
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=https://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/application/mysql/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 5000
MySQL查看报错:
[[email protected] scripts]# tail -100 /application/mysql/data/db01.err
连接MySQL:
[[email protected] scripts]# mysql
查看库:
mysql> show databases;
以上是关于二进制安装mysql的主要内容,如果未能解决你的问题,请参考以下文章