標籤:mysql
環境: CentOS7
軟體:MySQL5.6.26
1 下載MySQL 源碼包
wget http://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.10/zabbix-2.2.10.tar.gz
2 解壓下載的檔案到/usr/local目錄並修改檔案夾名稱為mysql
tar -zxvf mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz -C /usr/localmv mysql-5.6.26-linux-glibc2.5-x86_64/ mysql
3建立Mysql使用者和使用者組
useradd mysql -s /sbin/nologin
4建立Mysql資料庫目錄並賦予許可權給Mysql使用者
mkdir -p /data/mysqlchown -R mysql:mysql /data/mysqlchown -R mysql:mysql /usr/local/mysql
5進入/usr/local/mysql目錄 初始化mysql
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
6 備份系統內建的my.cnf檔案,然後把Mysql解壓目錄中預設設定檔移過去
mv /etc/my.cnf /etc/my.cnf.bakcp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
7修改my.cnf檔案
datadir=/data/mysqlport=3306socket=/tmp/mysql.sock
8複製解壓目錄下面的mysql.server檔案到/etc/init.d/mysqld
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqldchmod 755 /etc/init.d/mysqldvi /etc/init.d/mysqlddatadir=/data/mysql #修改資料庫目錄檔案
9 啟動mysql服務
service mysqld startUsage: mysqld {start|stop|restart|reload|force-reload|status} [ MySQL server options ]
10 配置mysql的環境變數
echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profilesource /etc/profile
11 登入mysql
[[email protected] ~]# mysql -uroot -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.6.26 MySQL Community Server (GPL)Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql>
安裝完成
本文出自 “站在巨人的肩膀上看世界” 部落格,請務必保留此出處http://lixiaotao.blog.51cto.com/985722/1692864
CentOS 7 + MySQL