开始安装MySQL
1.安装依赖
yum -y install wget cmake gcc gcc-c++ ncurses ncurses-devel libaio-devel openssl openssl-devel autoconf
2.解压并创建用户和目录
[root@localhost env]# tar -zxvf mysql-5.6.46.tar.gz
[root@localhost env]# cd mysql-5.6.46/
[root@localhost mysql-5.6.46]# groupadd mysql
[root@localhost mysql-5.6.46]# useradd -r -g mysql -s /sbin/nologin mysql
[root@localhost mysql-5.6.46]# mkdir -p /usr/local/mysql
[root@localhost mysql-5.6.46]# mkdir -p /data/mysql
[root@localhost mysql-5.6.46]# chown -R mysql.mysql /usr/local/mysql/
[root@localhost mysql-5.6.46]# chown -R mysql.mysql /data/mysql/
[root@localhost mysql-5.6.46]# chmod -R 755 /data/mysql/
[root@localhost mysql-5.6.46]# chmod -R 755 /usr/local/mysql/
3.编译安装
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysql \
-DSYSCONFDIR=/etc \
-DMYSQL_TCP_PORT=3306 \
-DWITH_BOOST=/root/env/mysql-5.6.46/boost \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNODB_MEMCACHED=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1
4.初始化数据库
scripts/mysql_install_db --defaults-file=/etc/my.cnf --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
5.编辑配置文件,配置启动文件,环境变量
输入如下配置信息:
[client]
port=3306
socket=/tmp/mysql.sock
default-character-set=utf8
#user=root
#password=123
[mysqld]
server-id=1
#skip-grant-tables
port=3306
user=mysql
max_connections=200
socket=/tmp/mysql.sock
basedir=/usr/local/mysql
datadir=/data/mysql
pid-file=/data/mysql/mysql.pid
init-connect='SET NAMES utf8'
character-set-server=utf8
default-storage-engine=INNODB
log_error=/data/mysql/mysql-error.log
slow_query_log_file=/data/mysql/mysql-slow.log
[mysqldump]
quick
max_allowed_packet=16M
环境变量:
echo "PATH=/usr/local/mysql/bin:$PATH" >> /etc/profile
导出:
复制启动文件到系统服务启动目录
cp 源码包/support-files/mysql.server /etc/init.d/mysqld
编辑启动文件,配置安装路径和数据库路径(把datadir指向/data/mysql,把basedir指向/usr/local/mysql)
授权执行权限
chmod +x /etc/init.d/mysqld
6,启动mysqld服务
7.登录MySQL
password输入步骤直接回车空密码登录
8.验证安装版本
可以看到正式我们安装的MySQL版本
至此MySQL安装完毕