码迷,mamicode.com
首页 > 数据库 > 详细

二进制安装MySQL

时间:2020-07-08 23:01:56      阅读:90      评论:0      收藏:0      [点我收藏+]

标签:auto   --   iat   NPU   libc   lib   color   启动数据库   init   

下载mysql包,也可以自己上传到机器

[root@db01 ~]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.6.46-linux-glibc2.12-x86_64.tar.gz

 

一.安装

1.安装依赖
yum install -y ncurses-devel libaio-devel gcc gcc-c++ glibc cmake autoconf

2.解雅tgz的包
[root@db01 ~]# tar xf mysql-5.6.46-linux-glibc2.12-x86_64.tar.gz

3.移动目录
[root@db01 ~]# mv mysql-5.6.46-linux-glibc2.12-x86_64 /usr/local/

4.做软链接
[root@db01 ~]# ln -s /usr/local/mysql-5.6.46-linux-glibc2.12-x86_64 /usr/local/mysql

5.创建mysql用户
[root@db01 ~]# useradd mysql -s /sbin/nologin -M

6.拷贝配置文件和启动脚本
[root@db01 support-files]# cp my-default.cnf /etc/my.cnf
cp: overwrite ‘/etc/my.cnf’? y

[root@db01 support-files]# cp mysql.server /etc/init.d/mysqld


7.初始化数据库

[root@db01 ~]# cd /usr/local/mysql/scripts/
[root@db01 scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

--user:    指定用户
--basedir: 指定安装目录
--datadir: 指定数据目录

#初始化成功的标志是有两个ok,再看最后有没有error

 

二.配置环境和systemctl管理

8.配置环境变量
[root@db01 scripts]# vim /etc/profile.d/mysql.sh
export PATH=/usr/local/mysql/bin:$PATH

[root@db01 scripts]# source /etc/profile


9.配置systemctl管理mysql

[root@db01 scripts]# vim /usr/lib/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=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 5000

[root@db01 scripts]# systemctl daemon-reload

 

三.启动数据库

10.启动数据库
[root@db01 scripts]# systemctl start mysqld

11.确认启动

[root@db01 scripts]# ps -ef | grep mysql
mysql     12886      1  2 03:10 ?        00:00:00 /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
root      12921  10636  0 03:11 pts/1    00:00:00 grep --color=auto mysql

12.进入mysql
[root@db01 scripts]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.46 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type help; or \h for help. Type \c to clear the current input statement.

mysql>

 

二进制安装MySQL

标签:auto   --   iat   NPU   libc   lib   color   启动数据库   init   

原文地址:https://www.cnblogs.com/gspblog/p/13269442.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!