系统版本:LINUX centos release 6.5 2.6.32-431.el6.x86_64
MYSQL版本:MySQL-5.6.41-1.el6.x86_64
官网下载地址:https://dev.mysql.com/downloads/
1.点击链接MySQL Community
2.点击链接MySQL Community Server 5.6
3.选中与系统版本匹配的mysql版本
查看当前linux系统中的mysql服务
[[email protected] ~]# rpm -qa|grep -i mysql
MySQL-server-x.x.xx.x86_64
MySQL-client-x.x.xx..x86_64
卸载mysql服务
[[email protected] ~]# rpm -e MySQL-server-x.x.xx.x86_64
[[email protected] ~]# rpm -e MySQL-client-x.x.xx..x86_64
1.上传并解压mysql rpm
解压并查看
[[email protected] mysql]# tar -xzvf MySQL-5.6.41-1.el6.x86_64.rpm-bundle.tar
[[email protected] mysql]# ll
-rw-r--r--. 1 7155 31415 18896876 Jun 18 15:14 MySQL-client-5.6.41-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415 3391756 Jun 18 15:14 MySQL-devel-5.6.41-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415 89948924 Jun 18 15:14 MySQL-embedded-5.6.41-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415 57507364 Jun 18 15:15 MySQL-server-5.6.41-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415 1965492 Jun 18 15:16 MySQL-shared-5.6.41-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415 3969752 Jun 18 15:16 MySQL-shared-compat-5.6.41-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415 51822464 Jun 18 15:16 MySQL-test-5.6.41-1.el6.x86_64.rpm
2.按顺序安装rpm
先安装MySQL-server-5.6.41-1.el6.x86_64.rpm
[[email protected] mysql]# rpm -ivh MySQL-server-5.6.41-1.el6.x86_64.rpm
出现安装错误 需要依赖libaio.so.1()(64bit)
/usr/bin/perl is needed by MySQL-server-5.6.38-1.el6.x86_64
libaio.so.1()(64bit) is needed by MySQL-server-5.6.38-1.el6.x86_64
libaio.so.1(LIBAIO_0.1)(64bit) is needed by MySQL-server-5.6.38-1.el6.x86_64
libaio.so.1(LIBAIO_0.4)(64bit) is needed by MySQL-server-5.6.38-1.el6.x86_64
libnuma.so.1()(64bit) is needed by MySQL-server-5.6.38-1.el6.x86_64
libnuma.so.1(libnuma_1.1)(64bit) is needed by MySQL-server-5.6.38-1.el6.x86_64
libnuma.so.1(libnuma_1.2)(64bit) is needed by MySQL-server-5.6.38-1.el6.x86_64
安装libaio rpm,如果还有错误 先查看gcc环境是否安装
查看gcc是否安装
可以通过 :gcc -v ps -ef|grep gcc rpm -qa|grep -i gcc
[[email protected] ~]# gcc -v
[[email protected] ~]# ps -ef|grep gcc
[[email protected] ~]# rpm -qa|grep -i gcc
如果查询后为空 就需要重新添加gcc环境
安装libaio rpm
[[email protected] mysql]# rpm -ivh libaio-0.3.107-10.el6.x86_64.rpm
查看是否安装完成
[[email protected] mysql]# rpm -qa | grep libaio
libaio-0.3.107-10.el6.x86_64
离线部署mysql5.6 source 下载 密码:fye2
再重新安装MySQL-server-5.6.41-1.el6.x86_64.rpm
[[email protected] mysql]# rpm -ivh MySQL-server-5.6.41-1.el6.x86_64.rpm --force --nodeps
安装 MySQL-client-5.6.41-1.el6.x86_64.rpm
[[email protected] mysql]# rpm -ivh MySQL-client-5.6.41-1.el6.x86_64.rpm
启动mysql服务
[root@ xx.xx.xx mysql] service mysql start
查看默认生成的随机密码
[root@centos6 ~]# cat /root/.mysql_secret
如果查询为空,不为空可以忽略此步骤
###### 查询为空需要重新初始化数据库 ######
//根据自己系统的mysql目录
//进入mysql/bin 执行./mysql_install_db
[[email protected] /]# find -name *mysql*
//此处忽略不用的目录
./var/lib/mysql-files
./var/lib/mysql
./var/lib/mysql/mysql
./var/lib/mysql/mysql.sock
./usr/bin/mysql_waitpid
./usr/bin/mysqlaccess.conf
./usr/bin/mysql_embedded
./usr/bin/mysql_config_editor
./usr/bin/mysqldumpslow
./usr/bin/mysql_tzinfo_to_sql
./usr/bin/mysql_fix_extensions
./usr/bin/mysql_find_rows
./usr/bin/mysqladmin
./usr/bin/msql2mysql
./usr/bin/mysql_convert_table_format
./usr/bin/mysqldump
./usr/bin/mysql_setpermission
./usr/bin/mysql_upgrade
./usr/bin/mysql_zap
./usr/bin/mysqlimport
./usr/bin/mysqlslap
./usr/bin/mysql
./usr/bin/mysql_secure_installation
./usr/bin/mysqlaccess
./usr/bin/mysql_plugin
./usr/bin/mysqlhotcopy
./usr/bin/mysqlbinlog
./usr/bin/mysql_install_db
./usr/bin/mysql_config
./usr/bin/mysqlshow
./usr/bin/mysqltest
./usr/bin/mysqld_multi
./usr/bin/mysqlbug
./usr/bin/mysqlcheck
./usr/bin/mysqld_safe
//删除mysql/var下所有数据
[[email protected] /]# cd /var/lib/
[[email protected] /]# rm -rf mysql
//创建mysql目录
[[email protected] /]# mkdir mysql
//进入bin目录执行初始化./mysql_install_db
[[email protected] /]# cd /usr/bin
[[email protected] /]# ./mysql_install_db
//进入 /var/lib/mysql 查看文件 应该创建了表的信息
[[email protected] mysql]# ll
total 503856
-rw-rw---- 1 mysql mysql 56 Aug 10 08:42 auto.cnf
-rw-rw---- 1 mysql mysql 415236096 Aug 10 09:54 ibdata1
-rw-rw---- 1 mysql mysql 50331648 Aug 10 09:54 ib_logfile0
-rw-rw---- 1 mysql mysql 50331648 Aug 10 09:54 ib_logfile1
drwx------ 2 mysql mysql 4096 Aug 10 08:40 mysql
srwxrwxrwx 1 mysql mysql 0 Aug 10 08:42 mysql.sock
drwx------ 2 mysql mysql 4096 Aug 10 08:40 performance_schema
drwx------ 2 mysql mysql 4096 Aug 10 08:40 test
//对mysql文件修改权限
[[email protected] mysql]# chown mysql:mysql -R .
登录mysql
[[email protected] mysql]# mysql -uroot -p
提示输入新密码
开启远程连接
mysql> grant all privileges on *.* to '用户名称' @'远程连接的ip' identified by '远程连接密码';
mysql> flush privileges;
//还需要开启Linux对外的3306端口
[[email protected] ~]# vi /etc/sysconfig/iptables
//添加
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
//重启服务
[[email protected] ~]# /etc/init.d/iptables restart
//查看端口是否开放
[[email protected] ~]# /sbin/iptables -L -n
– The end –