你们如果要yum安装的话cue我哦!!!
mysql安装
关闭防火墙和selinux
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
getenforce
编译安装mysql5.7
1、清理安装环境
yum erase mariadb mariadb-server mariadb-libs mariadb-devel -y
userdel -r mysql
rm -rf /etc/my*
rm -rf /var/lib/mysql
2、创建mysql用户
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.27.tar.gz
4、安装编译工具
yum -y install ncurses ncurses-devel openssl-devel bison gcc gcc-c++ make cmake:
yum -y install cmake
5、创建mysql目录
mkdir -p /usr/local/{data,mysql,log}
6、解压
tar xzvf mysql-boost-5.7.27.tar.gz -C /usr/local/
注:如果安装的MySQL5.7及以上的版本,在编译安装之前需要安装boost,因为高版本mysql需要boots库的 安装才可以正常运行。否则会报CMake Error at cmake/boost.cmake:81错误 安装包里面自带boost包
7、编译安装
cd 解压的mysql目录
cd /usr/local/mysql-5.7.27/
cmake . \
-DWITH_BOOST=boost/boost_1_59_0/ \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DSYSCONFDIR=/etc \ -DMYSQL_DATADIR=/usr/local/mysql/data \
-DINSTALL_MANDIR=/usr/share/man \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_READLINE=1 \ -DWITH_SSL=system \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1
==================
make && make install
如果安装出错,想重新安装: 不用重新解压,只需要删除安装目录中的缓存文件CMakeCache.txt
==================
需要很长时间!大约半小时!!!!!!!!
8、初始化
cd /usr/local/mysql
chown -R mysql.mysql .
./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
---初始化完成之后,一 定要记住提示最后的密码用于登陆或者修改密码
===============
这条命令出来得最后, :后面就是你的密码,要记住哦!!!
==============
初始化,只需要初始化一次
vim /etc/my.cnf ---添加如下内容
==============
[mysqld]
basedir=/usr/local/mysql #指定安装目录
datadir=/usr/local/mysql/data #指定数据存放目录
9、启动mysql
cd /usr/local/mysql
./bin/mysqld_safe --user=mysql &
查看mysql端口
netstat -lntp | grep 3306
10、登录mysql
/usr/local/mysql/bin/mysql -uroot -p'GP9TKGgY9i/8'
===================
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 2
Server version: 5.7.27
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> exit
==================