标签:debug basedir 解压 dir evel flush mem build 0.00
1. 安装依赖yum install -y cmake bison bison-devel libaio-devel gcc gcc-c++ git ncurses-devel
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.20.tar.gz
wget https://zh.osdn.net/projects/sfnet_boost/downloads/boost/1.59.0/boost_1_59_0.tar.gz/
2. 解压编译安装
[root@mysql ~]# tar xf mysql-5.7.20.tar.gz
[root@mysql ~]# mv boost_1_59_0.tar.gz mysql-5.7.20
[root@mysql ~]# cd mysql-5.7.20
[root@mysql mysql-5.7.20]# mkdir configure
[root@mysql mysql-5.7.20]# cd configure
[root@mysql configure]# cmake .. -DBUILD_CONFIG=mysql_release \
-DINSTALL_LAYOUT=STANDALONE \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DENABLE_DTRACE=OFF \
-DWITH_EMBEDDED_SERVER=OFF \
-DWITH_INNODB_MEMCACHED=ON \
-DWITH_SSL=bundled \
-DWITH_ZLIB=system \
-DWITH_PAM=ON \
-DCMAKE_INSTALL_PREFIX=/var/mysql/ \
-DINSTALL_PLUGINDIR="/var/mysql/lib/plugin" \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EDITLINE=bundled \
-DFEATURE_SET=community \
-DCOMPILATION_COMMENT="MySQL Server (GPL)" \
-DWITH_DEBUG=OFF \
-DWITH_BOOST=..
[root@mysql configure]# make
[root@mysql configure]# make install # 此步骤很慢
3. 创建配置文件目录及用户
[root@mysql ~]# useradd -s /sbin/nologin mysql
[root@mysql ~]# mkdir -p /data/mysql
[root@mysql ~]# mkdir -p /var/mysql/log
[root@mysql ~]# chown -R mysql:mysql /data/mysql/
[root@mysql ~]# chown -R mysql:mysql /var/mysql/log
4. 修改配置文件
[root@mysql ~]# vim /etc/my.cnf
...
[mysqld]
datadir=/data/mysql
socket=/var/lib/mysql/mysql.sock
log_error=/var/mysql/log/error.log
basedir=/var/mysql
5. 初始化
[root@mysql ~]# /var/mysql/bin/mysqld --initialize --user=mysql
[root@mysql ~]# ll /data/mysql/
total 110628
-rw-r-----. 1 mysql mysql 56 Jul 10 17:51 auto.cnf
-rw-r-----. 1 mysql mysql 419 Jul 10 17:51 ib_buffer_pool
-rw-r-----. 1 mysql mysql 12582912 Jul 10 17:51 ibdata1
-rw-r-----. 1 mysql mysql 50331648 Jul 10 17:51 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648 Jul 10 17:51 ib_logfile1
drwxr-x---. 2 mysql mysql 4096 Jul 10 17:51 mysql
drwxr-x---. 2 mysql mysql 8192 Jul 10 17:51 performance_schema
drwxr-x---. 2 mysql mysql 8192 Jul 10 17:51 sys
[root@mysql ~]# ll /var/mysql/log/
total 4
-rw-r-----. 1 mysql mysql 802 Jul 10 17:51 error.log
6. 修改配置文件
[root@mysql ~]# cp /var/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@mysql ~]# vim /etc/init.d/mysqld #找到如下两行
...
basedir=/var/mysql/
datadir=/data/mysql
...
[root@mysql ~]# mkdir -p /var/lib/mysql
[root@mysql ~]# chown -R mysql:mysql /var/lib/mysql
7. 添加环境变量
[root@mysql mysql]# vim /etc/profile
...
MYSQL_HOME=/var/mysql/bin/
PATH=$PATH:$MYSQL_HOME
[root@mysql ~]# source /etc/profile
8 . 修改原始密码
[root@mysql ~]# cat /var/mysql/log/error.log | grep generated
2018-07-10T09:51:31.365809Z 1 [Note] A temporary password is generated for root@localhost: pS:SCG1goPhj
[root@mysql ~]# /etc/init.d/mysqld start
[root@mysql ~]# ln -s /var/lib/mysql/mysql.sock /tmp/
[root@mysql ~]# mysql -uroot -p
密码为: pS:SCG1goPhj
mysql> alter user 'root'@'localhost' identified by '123123';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
标签:debug basedir 解压 dir evel flush mem build 0.00
原文地址:http://blog.51cto.com/calabash/2140179