linux 安装mysql 5.7版本
2017-12-25 17:58
531 查看
写下本文为了是记录自己linux下安装mysql5.7 的过程
我是新安装的centos65 因为系统默认自带了 mysql5.1的一些包,所以安装时出现了错误,如下:我需要安装的时mysql 5.7 ,但是系统提示我 我安装的与现有的文件有冲突
[root@localhost mysql]# rpm -ivh mysql-community-common-5.7.20-1.el6.x86_64.rpm
warning: mysql-community-common-5.7.20-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
file /usr/share/mysql/czech/errmsg.sys from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/danish/errmsg.sys from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/dutch/errmsg.sys from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/english/errmsg.sys from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/estonian/errmsg.sys from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/french/errmsg.sys from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/german/errmsg.sys from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/greek/errmsg.sys from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/hungarian/errmsg.sys from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/italian/errmsg.sys from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/japanese/errmsg.sys from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/korean/errmsg.sys from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/norwegian-ny/errmsg.sys from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/norwegian/errmsg.sys from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/polish/errmsg.sys from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/portuguese/errmsg.sys from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/romanian/errmsg.sys from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/russian/errmsg.sys from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/serbian/errmsg.sys from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/slovak/errmsg.sys from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/spanish/errmsg.sys from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/swedish/errmsg.sys from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/ukrainian/errmsg.sys from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/charsets/Index.xml from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/charsets/armscii8.xml from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/charsets/ascii.xml from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/charsets/cp1250.xml from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/charsets/cp1256.xml from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/charsets/cp1257.xml from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/charsets/cp850.xml from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/charsets/cp852.xml from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/charsets/cp866.xml from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/charsets/dec8.xml from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/charsets/geostd8.xml from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/charsets/greek.xml from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/charsets/hebrew.xml from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/charsets/hp8.xml from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/charsets/keybcs2.xml from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/charsets/koi8r.xml from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/charsets/koi8u.xml from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/charsets/latin1.xml from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/charsets/latin2.xml from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/charsets/latin5.xml from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/charsets/latin7.xml from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/charsets/macce.xml from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/charsets/macroman.xml from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
file /usr/share/mysql/charsets/swe7.xml from install of mysql-community-common-5.7.20-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64
解决方法如下:
找到mysql已经有的文件
[root@localhost mysql]# rpm -qa|grep mysql
mysql-libs-5.1.71-1.el6.x86_64
强行删除
rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64 如果没有--nodeps 参数 可能会提示,包被其他程序依赖。
以上也许有人不会需要,所以不作为安装步骤写了。
下面就是安装mysql的正确过程了
(1)首先去官网下载安装包 https://dev.mysql.com/downloads/mysql/ 因为我的linux时centos6.5 属于Red Hat系列,所以我选择的是
Red Hat Enterprise Linux/Oracle Linux 系列 Red Hat Enterprise Linux/Oracle Linux(X86,64-bit)版本
下的
mysql-5.7.20-1.el6.x86_64.rpm-bundle.tar
这包里面包含 客户端,服务端,公共包等多项内容,其它的下载项则为单项内容
(2)上传到linux 我上传的目录为 /usr/local/mysql
解压
[root@localhost mysql]# tar -xvf mysql-5.7.20-1.el6.x86_64.rpm-bundle.tar
解压内容如下:
mysql-community-embedded-devel-5.7.20-1.el6.x86_64.rpm
mysql-community-common-5.7.20-1.el6.x86_64.rpm
mysql-community-client-5.7.20-1.el6.x86_64.rpm
mysql-community-test-5.7.20-1.el6.x86_64.rpm
mysql-community-server-5.7.20-1.el6.x86_64.rpm
mysql-community-devel-5.7.20-1.el6.x86_64.rpm
mysql-community-libs-compat-5.7.20-1.el6.x86_64.rpm
mysql-community-libs-5.7.20-1.el6.x86_64.rpm
mysql-community-embedded-5.7.20-1.el6.x86_64.rpm
(3)安装服务端,不成功,提示如下
[root@localhost mysql]# rpm -ivh mysql-community-server-5.7.20-1.el6.x86_64.rpm
warning: mysql-community-server-5.7.20-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
mysql-community-client(x86-64) >= 5.7.9 is needed by mysql-community-server-5.7.20-1.el6.x86_64
mysql-community-common(x86-64) = 5.7.20-1.el6 is needed by mysql-community-server-5.7.20-1.el6.x86_64
这说明我需要先安装 mysql-community-client 与 mysql-community-common 两项
(4)安装common成功
[root@localhost mysql]# rpm -ivh mysql-community-common-5.7.20-1.el6.x86_64.rpm
warning: mysql-community-common-5.7.20-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-common ########################################### [100%]
(5)安装 client 失败,提示如下:
[root@localhost mysql]# rpm -ivh mysql-community-client-5.7.20-1.el6.x86_64.rpm
warning: mysql-community-client-5.7.20-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
mysql-community-libs(x86-64) >= 5.7.9 is needed by mysql-community-client-5.7.20-1.el6.x86_64
(6)需要先再装 libs 成功
[root@localhost mysql]# rpm -ivh mysql-community-libs-5.7.20-1.el6.x86_64.rpm
warning: mysql-community-libs-5.7.20-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-libs ########################################### [100%]
(7)安装 客户端成功
[root@localhost mysql]# rpm -ivh mysql-community-client-5.7.20-1.el6.x86_64.rpm
warning: mysql-community-client-5.7.20-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-client ########################################### [100%]
(8)安装服务端成功
[root@localhost mysql]# rpm -ivh mysql-community-server-5.7.20-1.el6.x86_64.rpm
warning: mysql-community-server-5.7.20-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-server ########################################### [100%]
(9)mysql可以正常启动了,但是此时会告诉我没有登录权限,提示如下:
无密码登录 mysql
ERROR 1045 (28000): Access denied for user 'admin0'@'localhost' (using password: NO)
有密码登录 mysql -u root -p
password :root(无论正确与否)
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
解决办法:参看如下文章 http://blog.csdn.net/keepd/article/details/77151006
1,停止mysql服务
service mysqld stop
2,修改配置文件无密码登录
vi /etc/my.cnf
在最尾部加上
skip-grant-tables
保存
3,启动mysql
service mysqld start;
4,登录musql
mysql -u root
此处注意不要加-p
5,修改密码,mysql5.7用此语法
use mysql ;
update mysql.user set authentication_string=password('123456') where user='root' ;
6,回到第二步骤去掉加上的
skip-grant-tables
7、保存重启完成
有一部分人到这里(win 系统登录)还是不行,有可能是因为 虚拟机的时间与win的时间不一致,我就遇到了。
我的方法是 步骤,1,2,3 然后从别的 数据库里面,把 mysql库中user表内的数据复制过来,直接替换掉原有的 user数据,
因为我 按上面的 7个步骤后,一直提示我密码过期,改了无数次就是不行,所以才用了数据替换的方法。
(10)mysql 安装到哪里去了
指令 ps -ef|grep mysql 得出结果
root 17659 1 0 2011 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid
mysql 17719 17659 0 2011 ? 03:14:57 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --socket=/var/lib/mysql/mysql.sock
usr/bin/mysql 是指:mysql的运行路径
var/lib/mysql 是指:mysql数据库文件的存放路径
usr/lib/mysql 是指:mysql的安装路径
(11)
Linux下mysql主从同步备份master-slave详细配置
1、概要
首先要准备两台服务器,一台主服务器(Master),另一台从服务器(Slave),然后要保证Master与Slave的版本要相同且Master不能高于Slave的版本,一般稳健的做法都是使其版本相同,因为MySQL不同版本之间的binlog(二进制日志)格式可能会不一样,最后会导致同步出现异常。介绍先到这里,以下我们先确认两台服务器的信息:
主服务器(Master):
IP:172.16.2.233
系统:Linux(centos6.5 v10.10)
MySQL版本:5.7
需要同步的数据库名:sxm
用于同步的帐号:root
用于同步的密码:123456
————————————–
从服务器(Slave)
IP:172.16.2.234
系统:Linux(centos6.5 v10.10)
系统:Linux(centos6.5 v10.10)
需要同步的数据库名:sxm
注:以下的配置以及测试都是使用SSH来进行的
2、修改Master服务器的配置
#打开my.cnf配置文件
vi /etc/my.cnf
#键入 /server-id 找到server-id的位置,把以下内容对照设置进去,键入 i,激活输入状态
#注意,这里的Master与Slave的server-id不能相同
server-id = 1
log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 100M
binlog_do_db = myslave #如果需要同时同步多个数据库,请另起一行设置binlog_do_db=需要同步的数据库名称
binlog_ignore_db = mysql
3、在Master建立sxm数据库并建立相关的数据表
4、建立用于同步数据的帐号(同步数据使用)
#重启服务器
/etc/init.d/mysql restart
出错的可能
service mysqld start
MySQL Daemon failed to start.
Starting mysqld: [FAILED]
去查看日志 /var/log/mysqld.log
我遇到的是如下提示:
mysqld: File '/var/log/mysql/mysql-bin.index' not found (Errcode: 13 - Permission denied)
这是因为权限问题,我的mysql没有多我新建的 /var/log/mysql 文件的读写权限。
付权
chown mysql:mysql -R /var/log/mysql
启动ok
#进入mysql查看有没有生效
mysql -u root -p
mysql> show master status;
+——————+———-+————–+——————+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+——————+———-+————–+——————+
| mysql-bin.000001 | 106 | myslave | mysql |
+——————+———-+————–+——————+
#以上可以看出跟在my.cnf里设置的是一致的,在此要记下File以及Position的值,后面在Slave服务器上会用到
5、修改Slave服务器的配置
#具体的路径以及版本都与Master服务器一样
vi /etc/mysql/my.cnf
#请对照设置,如下
server-id = 2
replicate-do-db = sxm
binlog_ignore_db = mysql
有的文章说需要以下参数,其实mysql5.5以后这些参数废弃了,需要命令行执行 change master to master_host='masterIP', master_user='slave', master_password='slvaePASS'; 来实现
master-host = 172.16.2.233
master-user = root
master-password = 123456
master-port = 3306
master-connect-retry = 5
6、建立数据库并导入备份数据
7、重启Slave服务器上的mysql
service mysqld restart
重启错误可能出现
(1)mysqld: File '/var/log/mysql/mysql-bin.index' not found (Errcode: 13 - Permission denied)
这是因为权限问题,我的mysql没有多我新建的 /var/log/mysql 文件的读写权限。
付权
chown mysql:mysql -R /var/log/mysql
(2)[ERROR] unknown variable 'master-host=172.16.2.233'
其实mysql5.5以后这些参数废弃了,需要命令行执行 change master to master_host='masterIP', master_user='slave', master_password='slvaePASS'; 来实现
master-host = 172.16.2.233
master-user = root
master-password = 123456
master-port = 3306
master-connect-retry = 5
#配置Slave信息并启动Slave服务
mysql> CHANGE MASTER TO MASTER_HOST='172.16.2.233', MASTER_USER='root', MASTER_PASSWORD='123456', MASTER_LOG_FILE='mysql-bin.000002',MASTER_LOG_POS=154;
#以上的是关键,具体的MASTER_LOG_FILE以及MASTER_LOG_POS的数据,可以从Master服务器获得,如果不设置,将无法正常启动Slave服务
#启动Slave服务
mysql> start slave;
#查看同步状态
mysql> show slave status;
#当输入命令后会出现一大堆的状态,具体的看Slave_IO_Running以及Slave_SQL_Running的状态,如果都是Yes就代表正常
8、测试同步
#在Master服务器插入一条数据
mysql> use sxm;
mysql>
INSERT INTO sx_t_m_role(id,pid,role_type,role_code,role_name,company_id,remark,data_status)
VALUE(1,NULL,'主从同步','主从同步','主从同步',NULL,'主从同步','主从同步');
相关文章推荐
- linux下安装5.7版本的MySQL和卸载MySQL
- mysql 5.7 linux版本安装及Navicat for mysql 远程连接
- linux 下安装Mysql 5.7+版本
- Linux下通过yum来安装 mysql 5.1,以及以前的旧版本(因服务器网络问题,安装后无法连接,无法验证正确性)
- centos linux 版本下 安装apche php mysql 环境
- mysql学习足迹之一【linux环境下源码安装mysql-5.5.25版本数据库】
- Linux下安装两个mysql5.5以上版本
- 同机安装多个MySQL版本-MySQL 5.7源码安装流程详解
- linux - mysql 5.7安装
- Linux下安装MySql(版本5.5以上)
- Linux安装指定mysql版本
- 在 CentOS 7 中以命令行方式安装 MySQL 5.7.11 for Linux Generic 二进制版本
- 安装非编译版本的mysql-5.1.22-rc-linux-i686-glibc23.tar.gz
- mysql 5.7版本安装问题
- Linux编译安装与配置-MySQL(5.5,5.6)版本系(笔记)
- 在Linux系统下安装大于mysql5.5版本的数据库
- linux下安装mysql与旧版本冲突的解决方案
- mysql安装5.6.10版本(linux)
- MySQL 5.7及以上解压缩版本配置安装
- linux mysql5.6版本的安装配置过程