码迷,mamicode.com
首页 > 数据库 > 详细

mysql用yum安装and编译安装

时间:2019-10-16 23:37:19      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:bug   memcach   mbed   efi   support   lld   cts   用户   txt   

1.下载yum源
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm

wget ‘https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
2.安装mysql源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
3.查看mysql源是否安装成功
yum repolist enabled | grep "mysql.-community."
4.安装mysql
yum install mysql-community-server -y
5.关闭放火墙
systemctl stop firewalld
setenforce 0
5.开启mysql
systemctl start mysqld
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
产看状态
systemctl status mysqld
启动mysql,要知道在centos7中,没有了service命令,都是使用systemctl命令。注意启动的时候是start mysqld而不是mysql。
查看有哪些版本的mysql:
yum repolist all | grep mysql

已启动

参考链接
https://www.cnblogs.com/caoxb/p/9405323.html
https://www.jianshu.com/p/531cc35b15e7

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1.下载安装包
cd /usr/local/src
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.20.tar.gz
2.下载boost
wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
3.下载依赖包
yum install -y cmake bison bison-devel libaio-devel gcc gcc-c++ git ncurses-devel
4.解压mysql
tar -zxvf mysql-5.7.20.tar.gz
将boost压缩包移动至mysql
mv boost_1_65_1.tar.gz mysql-5.7.20
5.进入mysql原文件目录,新建configure作为编译目录,进入该目录
cd mysql-5.7.20
mkdir configure
cd configure
6.编译
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=..
如果编译错误,先删除CMakeCache。txt后,再重新编译
rm -rf CMakeCache.txt
如果出现下面的提示就表示成功生成了编译环境:
-- Configuring done
-- Generating done
7.make
成功编译
[100%] Building CXX object sql/CMakeFiles/udf_example.dir/udf_example.cc.o
Linking CXX shared module udf_example.so
[100%] Built target udf_example
[100%] Built target my_safe_process
8.make install
9.添加mysql用户
useradd -s /sbin/nologin mysql
10.新建数据库文件夹及日志文件夹,并更改用户为mysql
mkdir /mysql_data
mkdir /var/mysql/log
chown -R mysql:mysql /mysql_data/
chown -R mysql:mysql /var/mysql/log
建立文件,进入/var/mysql/log创建
touch error.log
赋权限子目录及文件
chmod -R 777 /var/mysql/log
11.修改配置文件
vim /etc/my.cnf
将[mysqld]项下的内容替换为:
[mysqld]
port=3306
datadir=/mysql_data
log_error=/var/mysql/log/error.log
basedir=/var/mysql/
注意:my.cnf文件有以下配置
socket=/var/lib/mysql/mysql.sock
需要手动建立mysql.sock,并赋值读写执行权限
chmod -R 777 mysql.sock
12.初始化数据库
/var/mysql/bin/mysqld --initialize --user=mysql
查看数据文件是否生成:

[root@localhost configure]# ll /mysql_data/
总用量 110620
-rw-r-----. 1 mysql mysql       56 10月  2 19:44 auto.cnf
-rw-r-----. 1 mysql mysql      419 10月  2 19:44 ib_buffer_pool
-rw-r-----. 1 mysql mysql 12582912 10月  2 19:44 ibdata1
-rw-r-----. 1 mysql mysql 50331648 10月  2 19:44 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648 10月  2 19:44 ib_logfile1
drwxr-x---. 2 mysql mysql     4096 10月  2 19:44 mysql
drwxr-x---. 2 mysql mysql     4096 10月  2 19:44 performance_schema
drwxr-x---. 2 mysql mysql    12288 10月  2 19:44 sys

查看日志文件是否生成:

[root@localhost mysql]# ll /var/mysql/log/
总用量 4
-rw-r-----. 1 mysql mysql 802 10月  2 19:47 error.log

13.
1.从模板文件中复制启动文件:

cp /var/mysql/support-files/mysql.server /etc/init.d/mysqld

  1. 修改启动文件:

vim /etc/init.d/mysql
找到如下二行:

basedir=
datadir=

修改为:

basedir=/var/mysql/
datadir=/mysql_data
  1. 启动mysql:

    [root@localhost mysql]# /etc/init.d/mysqld start
    Starting MySQL. SUCCESS!
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    下载mysql源安装包
    wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
    安装mysql源
    yum localinstall mysql57-community-release-el7-8.noarch.rpm
    检查mysql源是否安装成功
    yum repolist enabled | grep "mysql.-community."

安装MySQL
yum install mysql-community-server
启动MySQL服务
systemctl start mysqld
查看MySQL的启动状态
systemctl status mysqld

开机启动
systemctl enable mysqld
systemctl daemon-reload

mysql用yum安装and编译安装

标签:bug   memcach   mbed   efi   support   lld   cts   用户   txt   

原文地址:https://blog.51cto.com/14375805/2442982

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!