linux-Centos7安装mysql5.7.19
1.下载mysql
网址: https://dev.mysql.com/downloads/mysql/
2.选择源码包,通用版点击下载
直接下载就可以了,不用登录
3.解压编译
先安装相关依赖包
yum install
pcre pcre-devel zlib zlib-devel openssl openssl-devel gd gd-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel lua-devel
autoconf libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel libidn libidn-devel libtool libtool-libs libevent-devel libevent openldap openldap-devel nss_ldap openldap-clients openldap-servers libtool-ltdl libtool-ltdl-devel bison libgcrypt php-mcrypt libmcrypt libmcrypt-devel cmake gcc gcc-c++ ncurses-devel perl-Data-Dumper libicu-devel libquadmath-devel python-devel bzip2-devel
我也不做区分了;这些是搭建lnpm环境需要安装的相关依赖包,就全安装完了。
[root@localhost]#tar -zxvf mysql-5.7.19.tar.gz
[root@localhost]#cd mysql-5.7.19.tar.gz
创建数据目录
[root@localhost]#mkdir -p /data/mysql
先用cmake编译,没有这个命令需要先yum安装
[root@localhost mysql-5.7.19]# yum install cmake
安装好cmake完成!
[root@localhost]#cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ #这个是编译安装之后的mysql目录所在地,可自行更改
-DMYSQL_DATADIR=/data/mysql/ #这个指向数据目录
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock
-DSYSCONFDIR=/usr/local/mysql/conf/
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_MEMORY_STORAGE_ENGINE=1
-DWITH_READLINE=1
-DMYSQL_TCP_PORT=3306
-DENABLED_LOCAL_INFILE=1
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DMYSQL_USER=mysql
-DWITH_SSL=system
-DWITH_ZLIB=system -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost #从MySQL 5.7.5开始Boost库是必需安装的
可直接复制下方编译语句:
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ -DMYSQL_DATADIR=/data/mysql/ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DSYSCONFDIR=/usr/local/mysql/conf/ -DWITH_MYISAM_STORAGE_ENGINE= -DWITH_INNOBASE_STORAGE_ENGINE= -DWITH_BLACKHOLE_STORAGE_ENGINE= -DWITH_ARCHIVE_STORAGE_ENGINE= -DWITH_MEMORY_STORAGE_ENGINE= -DWITH_READLINE= -DMYSQL_TCP_PORT= -DENABLED_LOCAL_INFILE= -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_USER=mysql -DWITH_SSL=system -DWITH_ZLIB=system -DDOWNLOAD_BOOST= -DWITH_BOOST=/usr/local/boost
如下图:
编译之后make && make install 漫长的等待....之后就安装完成了
安装完成之后路径/usr/local/ 下面会有一个目录 mysql,这个目录就是我编译安装设置的路径-DCMAKE_INSTALL_PREFIX=/usr/local/mysql/
一般为了安全起见,我们都会创建一个mysql用户和mysql组,执行以下命令
#添加用户组
groupadd mysql
#添加用户mysql 到用户组mysql
useradd
-g mysql mysql
4.接下来配置启动向,设置开机启动
- cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
- chmod +x /etc/init.d/mysqld
- chkconfig --add mysqld
- chkconfig mysqld on
配置/etc/my.cnf,如果没有my.cnf可自行新建添加 , 仅供参考
[client]
port =
socket = /tmp/mysql.sock
default-character-set = utf8mb4
[mysqld]
port =
socket = /tmp/mysql.sock
basedir = /usr/local/mysql
datadir = /data/mysql
pid-file = /data/mysql/mysql.pid
user = mysql
bind-address = 0.0.0.0
server-id =
init-connect = 'SET NAMES utf8mb4'
character-set-server = utf8mb4
#skip-name-resolve
#skip-networking
back_log =
max_connections =
max_connect_errors =
open_files_limit =
table_open_cache =
max_allowed_packet = 4M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 16M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 4M
thread_cache_size =
query_cache_type =
query_cache_size = 8M
query_cache_limit = 2M
ft_min_word_len =
log_bin = mysql-bin
binlog_format = mixed
expire_logs_days =
log_error = /data/mysql/mysql-error.log
slow_query_log =
long_query_time =
slow_query_log_file = /data/mysql/mysql-slow.log
performance_schema =
explicit_defaults_for_timestamp
#lower_case_table_names =
skip-external-locking
default_storage_engine = InnoDB
#default-storage-engine = MyISAM
innodb_file_per_table =
innodb_open_files =
innodb_buffer_pool_size = 64M
innodb_write_io_threads =
innodb_read_io_threads =
innodb_thread_concurrency =
innodb_purge_threads =
innodb_flush_log_at_trx_commit =
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group =
innodb_max_dirty_pages_pct =
innodb_lock_wait_timeout =
bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 10G
myisam_repair_threads =
interactive_timeout =
wait_timeout =
[mysqldump]
quick
max_allowed_packet = 16M
[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M
接下来就执行初始化数据库语句:
注意 mysql_install_db 已经不再推荐使用了,建议改成 mysqld –initialize 完成实例初始化。
/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
这步很重要,如果没有初始化直接启动数据库会报错
ERROR! The server quit without updating PID file (/data/mysql/mysql.pid).
如果初始化失败或者报以下错误,就需要先清空你的/data/mysql目录了,因为mysql目录下面有数据所以初始化执行中止。
2017-08-29T13:39:47.241469Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2017-08-29T13:39:47.241536Z 0 [ERROR] Aborting
清空之后再重新初始化
/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
接下来可以启动mysql了
service mysqld start
登录测试
/usr/local/mysql/bin/mysql -uroot -p
因为初始化--initialize-insecure 是默认没有密码的所以密码不用输入直接确定就行了;
假如登录报错
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
检查一下你启动数据库成功没 可执行 ps -ef | grep mysql 看看进程是不是启动状态
空密码不安全所以我们还要设置密码,下面命令中的\"root\"就是设置密码区域,我的密码设置为root,可自行修改
[root@localhost local]# /usr/local/mysql/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"root\" with grant option;"
[root@localhost local]# /usr/local/mysql/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"root\" with grant option;"
接下来再登录测试一次密码修改成功没有就完成啦!
mysql查询sql有很多限制,比如sql查询语句分组查询之类的会有很多限制,设置sql宽松模式
配置文件里面添加sql_mode=STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION
查看默认sql_mode配置,登录到>mysql执行命令select @@sql_mode;即可查看
linux-Centos7安装mysql5.7.19的更多相关文章
- Linux CentOS7 安装 Mysql5.7.19
第二次安装会安装失败 1.先停止mysql服务 service mysql stop 2.检查是否卸载干净 find / -name mysql 多用几个命令检查,不要删到其他组件的 ...
- centos7安装mysql5.7.19及配置远程连接
centos7安装mysql5.7.19及配置远程连接------https://blog.csdn.net/Lh19931122/article/details/77996213
- linux centos7 安装mysql-5.7.17教程(图解)
1系统约定安装文件下载目录:/data/softwareMysql目录安装位置:/usr/local/mysql数据库保存位置:/data/mysql日志保存位置:/data/log/mysql 2下 ...
- window和linux(centos7)安装mysql5.7
window mysql 安装步骤 社区版本下载地址: https://dev.mysql.com/downloads/file/?id=474802 下载完成后,得到mysql-installer- ...
- Centos7安装mysql-5.7.19
Centos7安装Mysql 一 mysql下载 地址: https://dev.mysql.com/downloads/mysql/#downloads 二 在centos7上创建安装文件存放.解压 ...
- 【环境部署】centos7安装mysql-5.7.19 group-replication
--mysql高可用官方文档: https://dev.mysql.com/doc/refman/5.7/en/group-replication.html mysql下载地址: https://ww ...
- Linux CentOS7安装Mysql5.7
一.下载mysql mkdir /home/install #创建install目录 在/home/install目录下下载mysql5.7 wget https://cdn.mysql.com//D ...
- CentOS7.2安装mysql-5.7.19多实例
安装多实例之前首先需要先安装mysql,这里就不介绍如何安装mysql了,参考前面的博客:https://www.cnblogs.com/hei-ma/p/9505509.html 安装多实例之前需要 ...
- 转:Linux 编译安装 Mysql5.7
http://broqiang.com/2017/04/18/Mysql-Install-5.7.18-Linux-Compile/ 原文 Linux 编译安装 Mysql5.7 Ubuntu 下快速 ...
- Centos7 安装 MySQL5.7
Centos7 安装 MySQL5.7 一.环境介绍 1.安装包版本介绍 MySQL 有三种安装方式:RPM安装.二进制包安装.源码包安装.我们这篇文章以二进制方式安装MySQL 软件名称 版本 系统 ...
随机推荐
- Creating an generated Earth AVI with C++
Creating an generated Earth AVI with C++ EarthGenerator.cpp /* EarthGenerator.cpp An examp ...
- Zen Cart屏蔽中文语言浏览器
在根目录下的index.php前面加上以下这段代码即可: if(preg_match("/zh-cn/is",$_SERVER['HTTP_ACCEPT_LANGUAGE'])){ ...
- Protobuf 数据类型
.proto Type Notes C++ Type Java Type double double double float float float int32 Uses var ...
- zabbix 4.0 安装配置
1.安装软件包: 1.安装软件包: yum install -y httpd mariadb-server mariadb php php-mysql php-gd libjpeg* php-ldap ...
- rmp-st算法
struct RMQ { ]; void init(int n) { ; i <= n; i ++)log2[i] = (i == ? - : log2[i >> ] + ); ; ...
- Codeforces Round #112 (Div. 2) D. Beard Graph
地址:http://codeforces.com/problemset/problem/165/D 题目: D. Beard Graph time limit per test 4 seconds m ...
- Windows 配置安卓环境变量
变量名:JAVA_HOME 变量值:JDK 路径 变量名:CLASSPATH 变量值:.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\toos.jar // ...
- 在vue项目中使用codemirror插件实现代码编辑器功能(代码高亮显示及自动提示
在vue项目中使用codemirror插件实现代码编辑器功能(代码高亮显示及自动提示) 1.使用npm安装依赖 npm install --save codemirror; 2.在页面中放入如下代码 ...
- C++ 顺序表实现
线性表就是字面上的意思, 顺序表是线性表基于数组的一种实现, “顺序”这个名字怎么来的并不清楚,可以勉强解释为“存储地址是连续.顺序的”. 另外两种线性表实现分别是“基于链表”和“散列存储”. 顺序表 ...
- jquery阻止事件冒泡的方法
$("table tbody").click(function(e) { e.preventDefault(); //阻止自身的事件,并不能阻止冒泡 e.stopPropagati ...