mysql5.6编译安装

1.添加用户

[root@web01 tools]# useradd -s /sbin/nologin  -M mysql
[root@lb01 ~]# id mysql
uid=27(mysql) gid=27(mysql) groups=27(mysql)

2.安装相关依赖

yum install ncurses-devel libaio-devel -y
rpm -qa ncurses-devel libaio-devel 
yum install cmake -y
rpm -qa cmake 

3.下载mysql并解压

cd /data
wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.14.tar.gz
tar xf mysql-5.6.34.tar.gz -C /data/
cd /data/mysql-5.6.34

4.cmake指定路径

cmake . -DCMAKE_INSTALL_PREFIX=/data/mysql-5.6.34 \
-DMYSQL_DATADIR=/data/mysql-5.6.34/data \
-DMYSQL_UNIX_ADDR=/data/mysql-5.6.34/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_ZLIB=bundled \
-DWITH_SSL=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLE_DOWNLOADS=1 \
-DWITH_DEBUG=0

4.1编译安装

make && make install

5 建立软连接  #防错

ln -s /data/mysql-5.6.34/ /data/mysql

6.初始化数据库

cp support-files/my*.cnf /etc/my.cnf
cd  /application/mysql
/data/mysql/scripts/mysql_install_db --basedir=/data/mysql/ --datadir=/data/mysql/data --user=mysql

7.设置权限,加入开机自启动

chown -R mysql.mysql /data/mysql/

8 设置mysql命令

echo 'PATH=/data/mysql/bin/:$PATH' >>/etc/profile
tail -1 /etc/profile
source /etc/profile
echo $PATH
mysql

9 设置密码

mysqladmin -u root password 'oldboy123'
mysql -uroot -poldboy123

10.解决报错

故障:ERROR! The server quit without updating PID file

    1.权限.chown -R mysql.mysql

    2.killall mysqld

2.报错

[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

(中文大意:强烈建议不要使用带有隐式默认值的TIMESTAMP。请使用explicit_defaults_for_timestamp选项)

在/etc/my.cnf下添加

explicit_defaults_for_timestamp=true



你可能感兴趣的:(mysql)