CentOS7安装MySQL 5.7
2024-08-24 14:09:43
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、官方文档
最新文章
- log4net 中错误 System.Web.HttpException (0x80004005): 文件不存在
- 关于position:absolute的困惑
- (转)【ASP.NET Web API】Authentication with OWIN
- POJ3107 (树的重心)
- C++描述基础算法之直接插入排序
- sql查询某段时间内的数据
- ZooKeeper应用场景
- 七、rdd究竟是什么
- PHP格式化字符串函数 sprintf()
- zend framework 1 安装教程
- 在nagios中使用python脚本监控linux主机
- Java关于数字工具类~持续汇总~
- 获取APP的元素信息和Activity
- c++与java的几个不同点
- PAT 1084 Broken Keyboard
- 你不知道的js
- python中那些双下划线开头得函数和变量
- MySQL基础值 存储过程和函数
- Ubuntu x86-64汇编(5) 控制指令
- ES6-fetch
热门文章
- 一款基于css3鼠标经过圆形旋转特效
- Parallelism , Partitioner
- Odoo ParseError:";decoder jpeg not available"; while parsing....
- ar命令学习
- 16c554 的头文件
- openresty 视频
- Spring Cloud对于中小型互联网公司来说是一种福音
- DFS应用——遍历有向图+判断有向图是否有圈
- 【NOIP模拟题】“与”(位运算)
- hdu 4291(矩阵+暴力求循环节)