1、源码包下载
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.20.tar.gz
2、编译安装
安装依赖包:
yum install cmake bison libaio-devel gcc gcc-c++ ncurses ncurses-devel -y
创建临时目录:
cd mysql-5.7./
mkdir debug
编译: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=/home/mysql \
-DINSTALL_PLUGINDIR="/home/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=../boost 安装:make -j && make install
3、安装成功如下
-- Installing: /home/mysql/mysql-test/./t/xa.test
-- Installing: /home/mysql/mysql-test/./t/xa_debug.test
-- Installing: /home/mysql/mysql-test/./t/xa_gtid-master.opt
-- Installing: /home/mysql/mysql-test/./t/xa_gtid.test
-- Installing: /home/mysql/mysql-test/./t/xa_prepared_binlog_off-master.opt
-- Installing: /home/mysql/mysql-test/./t/xa_prepared_binlog_off.test
-- Installing: /home/mysql/mysql-test/./t/xml.test
-- Installing: /home/mysql/mysql-test/./valgrind.supp
-- Installing: /home/mysql/./COPYING-test
-- Installing: /home/mysql/./README-test
-- Installing: /home/mysql/mysql-test/mtr
-- Installing: /home/mysql/mysql-test/mysql-test-run
-- Installing: /home/mysql/mysql-test/lib/My/SafeProcess/my_safe_process
-- Up-to-date: /home/mysql/mysql-test/lib/My/SafeProcess/my_safe_process
-- Installing: /home/mysql/mysql-test/lib/My/SafeProcess/Base.pm
-- Installing: /home/mysql/support-files/mysqld_multi.server
-- Installing: /home/mysql/support-files/mysql-log-rotate
-- Installing: /home/mysql/support-files/magic
-- Installing: /home/mysql/share/aclocal/mysql.m4
-- Installing: /home/mysql/support-files/mysql.server
4、创建配置文件
mkdir /home/{mysql_data, mysql_log}
vim /home/mysql_data/my.cnf
[mysqld]
port=
datadir=/home/mysql_data
log_error=/home/mysql_log/error.log
basedir=/home/mysql
5、创建MySQL库
添加用户:
groupadd mysql
useradd -g mysql mysql -s /sbin/nologin
6、启动数据库
初始化:
./bin/mysqld --defaults-file=/etc/my.cnf --basedir=/home/mysql --datadir=/home/mysql_data --user=mysql --initialize
启动:
/home/mysql/bin/mysqld --defaults-file=/home/mysql_data/my.cnf --user=mysql 查看进程:
[root@master2 home]# ps aux | grep mysql
mysql 2.0 1.1 pts/ Sl+ : : /home/mysql/bin/mysqld --defaults-file=/etc/my.cnf --user=mysql
7、登录数据库
查看初始密码:
[root@master2 home]# grep "root@localhost" /home/mysql_log/error.log
--04T06::.468338Z [Note] A temporary password is generated for root@localhost: #3vslHQt;m- 登录数据库并修改密码:
[root@master2 home]# mysql -uroot -p5#3vslHQt;m-
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR (): Access denied for user 'root'@'localhost' (using password: YES)
-bash: m-: command not found
[root@master2 home]# mysql -uroot -p"5#3vslHQt;m-"
mysql: [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
Server version: 5.7. Copyright (c) , , 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> SET PASSWORD="ROOT_NEW_PASSWORD";
Query OK, rows affected (0.00 sec) mysql> ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
Query OK, rows affected (0.00 sec) mysql> FLUSH PRIVILEGES;
Query OK, rows affected (0.00 sec)
8、官方文档