[root@web01 ~]# wget
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.建立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.初始化資料庫[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: 指定資料目錄
# 初始化成功的標誌是兩個ok
8.啟動資料庫[root@m01 scripts]# /etc/init.d/mysqld start
9.配置環境變數[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=
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啟動的時候先執行/etc/init.d/mysqld stop
11.確認啟動[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)
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
# 啟動失敗,因為mysql檔案中很多都是 /usr/local/mysql,我們需要替換,但只需要替換兩個檔案中的內容即可
[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!
二進位制如何安裝mysql 二進位制安裝mysql
1.建立安裝目錄 wget 3.解壓二進位製包 root db01 tar xf mysql 5.6.40 linux glibc2.12 x86 64.tar.gz 4.移動解壓目錄 5.做mysql軟連線 6.建立mysql使用者 root db01 useradd mysql s sbin n...
MySQL二進位制安裝
1 進入使用者家目錄建立tools資料夾 3 新增mysql使用者和使用者組 1 groupadd mysql 2 useradd g mysql mysql 4 解壓二進位制安裝包 1 tar zxvf mysql 5.6.12 linux glibc2.5 x86 64.tar.gz 6 將解壓...
二進位制安裝MySQL
規劃項 實際值系統 戶及密碼 mysql 安裝介質位置 tmp mysql軟體路徑 usr local mysql mysql資料 件路徑 data mysql data mysql 志檔案 data mysql logs mysql binlog data mysql binlogs rpm qa...