一、环境说明

服务器:阿里云CentOS7.4 64位

mysql版本:MySQL-5.6.33-1.linux_glibc2.5.x86_64.rpm-bundle.tar

二、安装前检查

防止有些镜像中有安装一些数据,这些数据库可能会导致mysql在安装过程中出现一些奇怪的错误,所以在安装之前还是检查一下:先检查是否有安装其他版本的mysql:

执行命令:rpm -qa | grep mysql (注意大小写,如果mysql 不行就换MySQL)检查是否有安装mariadb:

执行命令:rpm -qa|grep mariadb

有就卸载:

rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64

三、安装过程先将mysql安装文件上传服务器指定目录,并解压;第一执行server文件的安装;第二执行devel文件的安装;第三执行client文件的安装;复制配置文件到ect: 命令:cp /usr/share/mysql/my-default.cnf /etc/my.cnf执行安装脚本/usr/bin/mysql_install_db启动数据库设置密码(/usr/bin/mysqladmin -u root password 'new-password'):用新密码登录mysql:

修改mysql的用户表并且赋权:修改字符集防止中文乱码,进入/etc/my.cnf :

# For advice on how to change settings please see

# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html

# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the

# *** default location during install, and will be replaced if you

# *** upgrade to a newer version of MySQL.

[client]

default-character-set=utf8

[mysqld]

character_set_server=utf8

character_set_client=utf8

collation-server=utf8_general_ci

lower_case_table_names=1

max_connections=1000

# Remove leading # and set to the amount of RAM for the most important data

# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.

# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging

# changes to the binary log between backups.

# log_bin

# These are commonly set, remove the # and set as required.

# basedir = .....

# datadir = .....

# port = .....

# server_id = .....

# socket = .....

# Remove leading # to set options mainly useful for reporting servers.

# The server defaults are faster for transactions and fast SELECTs.

# Adjust sizes as needed, experiment to find the optimal values.

# join_buffer_size = 128M

# sort_buffer_size = 2M

# read_rnd_buffer_size = 2M

[mysql]

default-character-set=utf8

#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES重启数据库,到这里基本上就安装完成。

四、其他异常情况说明执行rpm -ivh MySQL-server-5.6.33-1.linux_glibc2.5.x86_64.rpm 安装过程中报错libaio.so.1()(64bit) is needed by MySQL-server-5.6.33-1.linux_glibc2.5.x86_64 异常解决:

这个是缺少libaio,可以执行:yum install libaio 安装即可:

安装成功后,继续执行安装命令。FATAL ERROR: please install the following Perl modules before executing /usr/bin/mysql_install_db: Data::Dumper异常解决:

实际是缺少安装autoconf库:执行命令:yum -y install autoconf //此包安装时会安装Data:Dumper模块

这种错误先找到错误日志,我这里进入到默认安装目录/var/lib/mysql 下找到错误日志:iZuf6emmmii2i6bh7eedujZ.err 跟上面的pid是同名的:

可以看出是没有权限,那么就赋权:

Logo

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。

更多推荐