mysql二进制安装的优缺点_MYSQL的二进制安装
1.下載mysql包
[root@web01 ~]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.6.46-linux-glibc2.12-x86_64.tar.gz
2.安裝依賴
[root@m01 ~]# yum install -y ncurses-devel libaio-devel gcc gcc-c++ glibc cmake autoconf openssl openssl-devel
3.解壓到/usr/local/
[root@m01 ~]# tar xf mysql-5.6.46-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
4.做軟連接
[root@m01 ~]# ln -s /usr/local/mysql-5.6.46-linux-glibc2.12-x86_64 /usr/local/mysql
5.創(chuàng)建mysql用戶
[root@m01 ~]# useradd mysql -s /sbin/nologin -M
6.拷貝配置文件和啟動腳本
[root@m01 support-files]# cp my-default.cnf /etc/my.cnf
cp: overwrite ‘/etc/my.cnf’? y
[root@m01 support-files]# cp mysql.server /etc/init.d/mysqld
7.初始化數(shù)據(jù)庫
[root@m01 ~]# cd /usr/local/mysql/scripts/
[root@m01 scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
--user:指定用戶
--basedir: 指定安裝目錄
--datadir: 指定數(shù)據(jù)目錄
# 初始化成功的標(biāo)志是兩個ok
8.啟動數(shù)據(jù)庫
[root@m01 scripts]# /etc/init.d/mysqld start
9.配置環(huán)境變量
[root@m01 scripts]# vim /etc/profile.d/mysql.sh
export PATH=/usr/local/mysql/bin:$PATH
[root@m01 scripts]# source /etc/profile
10.配置system管理
[root@m01 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@m01 scripts]# systemctl daemon-reload
[root@m01 scripts]# systemctl start mysqld
#### 前面我們用的/etc/init.d/mysqld start啟動,所以我們用system啟動的時候先執(zhí)行/etc/init.d/mysqld stop
11.確認(rèn)啟動
[root@m01 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
[root@m01 scripts]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp6 0 0 :::3306 :::* LISTEN 12886/mysqld
[root@m01 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>
12.指定安裝其他目錄(非/usr/local/)遇到以下問題,解決方案
[root@m01 scripts]# /etc/init.d/mysqld start
# 啟動失敗,因?yàn)閙ysql文件中很多都是 /usr/local/mysql,我們需要替換,但只需要替換兩個文件中的內(nèi)容即可
[root@m01 mysql]# sed -i 's#/usr/local/mysql#/service/mysql#g' /etc/init.d/mysqld /service/mysql/bin/mysqld_safe
# 修改配置文件
[root@m01 mysql]# vim /etc/my.cnf
basedir = /service/mysql
datadir = /service/mysql/data
# 再次啟動
[root@m01 mysql]# /etc/init.d/mysqld start
Starting MySQL.Logging to '/service/mysql/data/db03.err'.
SUCCESS!
總結(jié)
以上是生活随笔為你收集整理的mysql二进制安装的优缺点_MYSQL的二进制安装的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Mysql 连接池session_Hib
- 下一篇: mysql怎么定位错误信息_Mysql主