|
MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,目前属于 Oracle 旗下产品。MySQL 是最流行的关系型数据库管理系统之一,在 WEB 应用方面,MySQL是最好的 RDBMS (Relational Database Management System,关系数据库管理系统) 应用软件。
MySQL是一种关系数据库管理系统,关系数据库将数据保存在不同的表中,而不是将所有数据放在一个大仓库内,这样就增加了速度并提高了灵活性。
MySQL所使用的 SQL 语言是用于访问数据库的最常用标准化语言。MySQL 软件采用了双授权政策,分为社区版和商业版,由于其体积小、速度快、总体拥有成本低,尤其是开放源码这一特点,一般中小型网站的开发都选择 MySQL 作为网站数据库。
查看当前系统版本的详细信息
[root@VM_159_140_centos ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)下载
5.5、5.6、5.7下载地址
[root@VM_159_140_centos lnmp]# wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-boost-5.7.26.tar.gz解压进入目录
[root@VM_159_140_centos lnmp]# tar -xzxvf mysql-boost-5.7.26.tar.gz
[root@VM_159_140_centos lnmp]# cd mysql-8.0.15/boost下载
这个版本的MySQL要求boost的版本是1.59,链接为:
[root@VM_159_140_centos lnmp]# wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
[root@VM_159_140_centos lnmp]# tar zxvf boost_1_59_0.tar.gz
[root@VM_159_140_centos lnmp]# cp -r boost_1_59_0 /usr/local/boost安装依赖
[root@VM_159_140_centos mysql-8.0.15]# yum -y install make gcc-c++ cmake bison-devel ncurses-devel创建mysql用户组和用户,用来运行mysql服务器, -g指定用户组, -r创建系统用户
[root@VM_159_140_centos lnmp]# groupadd mysql
[root@VM_159_140_centos lnmp]# useradd -r -g mysql -s /bin/false -M mysql编译参数
[root@VM_159_140_centos mysql-5.7.26]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql57 -DMYSQL_DATADIR=/usr/local/mysql57/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DENABLE_DOWNLOADS=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost
检验是否配置成功
echo $? 是0代表OK
配置
详细参数参考王志强:MySQL CMake参数说明手册
如果编译出现错误,请先删除CMakeCache.txt后,再重新编译:
[root@VM_159_140_centos mysql-5.7.26]# rm -rf CMakeCache.txt编译安装
[root@VM_159_140_centos mysql-5.7.26]# make && make install编译安装成功

将mysql添加到环境变量
[root@VM_159_140_centos mysql-5.7.26]# vim /etc/profile
# 最后一行添加
export PATH=/usr/local/mysql57/bin:/usr/local/mysql57/lib:$PATH
[root@VM_159_140_centos mysql-5.7.26]# source /etc/profile 修改配置文件/etc/my.cnf
[mysqld]
datadir=/usr/local/mysql57/data
socket=/usr/local/mysql57/mysql.sock
user = mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
log-error=/usr/local/mysql57/logs/mysqld.log
pid-file=/usr/local/mysql57/pids/mysqld.pid
[client]
default-character-set=utf8
socket=/usr/local/mysql57/mysql.sock
[mysql]
default-character-set=utf8
socket=/usr/local/mysql57/mysql.sock
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d初始化数据库(最关键目的得到root密码)
[root@VM_159_140_centos mysql-5.7.26]# mysqld_safe --basedir=/usr/local/mysql57 --datadir=/usr/local/mysql57/data --user=mysql
将mysql服务文件拷贝到/etc/init.d/目录,并给出执行权限
[root@VM_159_140_centos mysql-5.7.26]# cp /www/lnmp/mysql-5.7.26/support-files/mysql.server /etc/init.d/mysqld57
[root@VM_159_140_centos mysql-5.7.26]# chmod a+x /etc/init.d/mysqld57将MySQL并加入开机自动启动
[root@VM_159_140_centos ~]# chkconfig --add mysqld57
[root@VM_159_140_centos ~]# chkconfig mysqld57 on
[root@VM_159_140_centos ~]# chkconfig --list | grep mysqld57
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'.
mysqld57 0:off 1:off 2:on 3:on 4:on 5:on 6:off初始化数据库
[root@VM_159_140_centos ~]# mysqld_safe --basedir=/usr/local/mysql57 --datadir=/usr/local/mysql57/data --user=mysql赋予目录mysql权限
[root@VM_159_140_centos mysql-5.7.26]# chown -R mysql:mysql /usr/local/mysql57
启动服务
[root@VM_159_140_centos ~]# service mysql57 start 关闭服务
[root@VM_159_140_centos ~]# service mysql57 stop
大坑进行实践
Starting MySQL.. ERROR! The server quit without updating PID file (/usr/local/mysql57/data/VM_159_140_centos.pid).1.给予权限,执行 "chown -R mysql.mysql /usr/local/mysql57/data/" 然后重新启动mysqld
2.进程占用 执行"ps -ef|grep mysqld" 查看是否有mysqld进程,如果有就"kill" 掉
3.datadir目录,/etc/my.cnf查看在[mysqld]下有没有指定数据目录(datadir)
4.skip-federated字段问题,/etc/my.cnf配置文件注释掉的skip-federated字段
5.错误日志目录不存在,使用“chown” “chmod”命令赋予mysql所有者及权限 |
|