1、 環境準備mysql
Linux CentOS7.3系統一臺主機便可;sql
MYSQL官網:https://www.mysql.com/數據庫
MYSQL軟件下載:http://ftp.kaist.ac.kr/mysql/Downloads/MySQL-5.6/server
2、 MYSQL的編譯和安裝排序
1:準備工做ip
[root@localhost ~]# rpm -q mysql-server mysql //查看mysql是否已經安裝ci
[root@localhost ~]# cd /media/cdrom/Packages/ //進入光盤所在目錄字符串
[root@localhost Packages]# rpm -ivh ncurses-devel-5.7-3.20090208.el6.x86_64.rpm //安裝軟件get
ncurses是字符終端下屏幕控制的基本庫,包括面板和菜單功能,在TTY下登陸到主機上mysql須要的。it
[root@localhost Packages]# cd
[root@localhost ~]# tar zxvf cmake-2.8.6.tar.gz //解包
[root@localhost ~]# cd cmake-2.8.6
[root@localhost cmake-2.8.6]# ./configure //配置
[root@localhost cmake-2.8.6]# gmake && gmake install //編譯安裝
2:安裝mysql
[root@localhost cmake-2.8.6]# cd
[root@localhost ~]# groupadd mysql
[root@localhost ~]# useradd -M -s /sbin/nologin mysql -g mysql
[root@localhost ~]# cd /usr/src
[root@localhost src]# tar zxvf mysql-5.6.36.tar.gz
[root@localhost src]# cd mysql-5.6.36
[root@localhost mysql-5.6.36]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all
-DDEFAULT_COLLATION:用於指定數據集如何排序,以及字符串的比對規則
[root@localhost mysql-5.6.36]# make
[root@localhost mysql-5.6.36]# make install
3:安裝後的調整
[root@localhost mysql-5.6.36]# cd
[root@localhost ~]# chown -R mysql:mysql /usr/local/mysql/
[root@localhost ~]# rm -rf /etc/my.cnf
[root@localhost ~]# cd mysql-5.6.36
[root@localhost mysql-5.6.36]# cp support-files/my-default.cnf /etc/my.cnf
4:初始化數據庫
[root@localhost mysql-5.6.36]# yum -y install autoconf
[root@www mysql-5.6.36]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/
[root@localhost mysql-5.6.36]# echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
[root@localhost mysql-5.6.36]# . /etc/profile \\點後有個空格
5:添加系統服務
方法1:
[root@localhost mysql-5.6.36]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@localhost mysql-5.6.36]# chmod +x /etc/rc.d/init.d/mysqld
[root@localhost mysql-5.6.36]# chkconfig --add mysqld
[root@localhost mysql-5.6.36]# service mysqld start
[root@localhost mysql-5.6.36]# /etc/init.d/mysqld status
[root@localhost mysql-5.6.36]# netstat -anpt | grep mysqld
[root@localhost mysql-5.6.36]# mysqladmin -u root password 'pwd123'
6:訪問mysql
[root@localhost ~]# mysql -u root -p
輸入相應的密碼;
mysql> show master logs;
mysql> exit