1:下载mysql5.6
[[email protected] ~]# wget https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.6/mysql-5.6.43.tar.gz
2:安装依赖
[[email protected] tools]# yum install -y ncurses-devel libaio-devel gcc gcc-c++ bison
3:安装cmake
[[email protected] tools]# yum install -y cmake
4:创建用户
[[email protected] tools]# useradd mysql -s /sbin/nologin -M
5:修改hosts
[[email protected] ~]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.6.181 mysql181
6:解压, cd mysql-5.6.43/
[[email protected] tools]# tar xf mysql-5.6.43.tar.gz
[[email protected] tools]# cd mysql-5.6.43/
7:创建程序文件夹
[[email protected] mysql-5.6.43]# mkdir /application
8:编译
[[email protected] mysql-5.6.43]#
cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.6.43 \
-DMYSQL_DATADIR=/application/mysql-5.6.43/data \
-DMYSQL_UNIX_ADDR=/application/mysql-5.6.43/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
9:编译make && 安装make install
[[email protected] mysql-5.6.43]# make && make install
10:做软连接
[[email protected] application]# ln -s /application/mysql-5.6.43/ /application/mysql
11: 复制配置文件
[[email protected] mysql-5.6.43]# cp support-files/my-default.cnf /etc/my.cnf
12:服务启动脚本,并授权
[[email protected] mysql-5.6.43]# cp support-files/mysql.server /etc/init.d/mysqld
[[email protected] scripts]# chmod 700 /etc/init.d/mysqld
[[email protected] mysql-5.6.43]# chmod u+x /etc/init.d/mysqld
13:创建 tmp目录,整个文件夹授权
[[email protected] scripts]# mkdir /application/mysql-5.6.43/tmp
[[email protected] scripts]# chown -R mysql.mysql /application/mysql/
14:进入初始化命令的脚本,初始化数据库
[[email protected] scripts]# cd /application/mysql/scripts/
[[email protected] scripts]# ./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data --user=mysql
15:导入环境变量:
[[email protected] scripts]# echo ‘PATH=/application/mysql/bin/:$PATH‘ >>/etc/profile
[[email protected] scripts]# source /etc/profile
16: 启动,加入开机自启
[[email protected] mysql]# /etc/init.d/mysqld start
[[email protected] scripts]# chkconfig mysqld on
17:更改mysql root初始密码:
[[email protected] mysql]# mysqladmin -uroot password ‘123456‘
18:登录mysql:
[[email protected] mysql]# mysql -uroot -p123456
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.43 Source distribution
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
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>
到此mysql 5.6 编译安装成功!
------------------ ---------------------------------------------------------------------------------------------------------------
原文地址:https://www.cnblogs.com/jim-xu/p/11419099.html