1.下載mysql版本 下載最新版本:https://www.mysql.com/downloads/ 下載歷史版本:https://downloads.mysql.com/archives/community/ 2.上傳下載的mysql軟體到/usr/local/src 3.解壓mysql軟體到/ ...
1.下載mysql版本
下載最新版本:https://www.mysql.com/downloads/
下載歷史版本:https://downloads.mysql.com/archives/community/
2.上傳下載的mysql軟體到/usr/local/src
3.解壓mysql軟體到/usr/local/mysql
(1).cd /usr/local/src
(2). tar -xvzf mysql.tar.gz -C /usr/local/mysql
4.創建數據目錄
mkdir /data/mysql/{data,logs,tmp}
5.授權數據目錄和軟體目錄
如果沒有mysql用戶,先創建mysql用戶 useradd mysql
chown -R mysql.mysql /data/mysql
chown -R mysql.mysql /usr/local/mysql
6.查看一下有沒有/etc/my.cnf文件
如果沒有將/usr/local/mysql/my.cnf 拷貝到/etc下
修改my.cnf中的
basedir=/usr/local/mysql
datadir=/data/mysql/data
tmpdir = /data/mysql/tmp
log-error= /data/mysql/logs/error.log
slow_query_log_file = /data/mysql/logs/slow.log
general_log_file = /data/mysql/logs/mysql.log
log-bin = /data/mysql/data/mysql-bin
log-bin-index = /data/mysql/data/mysql-bin.index
relay-log = /data/mysql/logs/relay-log
relay_log_index = /data/mysql/logs/relay-log.index
7.初始化mysql
(1) cd /usr/local/mysql/scripts
(2) ./mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql/data --defaults-file=/etc/my.cnf --user=mysql
8.啟動mysql
/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf &
9. ps -ef|grep mysql 查看mysql是否啟動了,如果有進程,恭喜你,mysql安裝成功了