centos7 RPM方式安装MySQL5.7
1、下载Linux对应的RPM包,CentOS7对应的RPM包,如下:
[[email protected] soft]# unzip mysql-5.7-centos7.zip Archive: mysql-5.7-centos7.zip extracting: mysql-commercial-client-5.7.16-1.1.el7.x86_64.rpm extracting: mysql-commercial-embedded-5.7.16-1.1.el7.x86_64.rpm extracting: mysql-commercial-common-5.7.16-1.1.el7.x86_64.rpm extracting: mysql-commercial-libs-compat-5.7.16-1.1.el7.x86_64.rpm extracting: mysql-commercial-embedded-compat-5.7.16-1.1.el7.x86_64.rpm extracting: mysql-commercial-devel-5.7.16-1.1.el7.x86_64.rpm extracting: mysql-commercial-server-5.7.16-1.1.el7.x86_64.rpm extracting: mysql-commercial-test-5.7.16-1.1.el7.x86_64.rpm extracting: mysql-commercial-embedded-devel-5.7.16-1.1.el7.x86_64.rpm extracting: mysql-commercial-libs-5.7.16-1.1.el7.x86_64.rpm extracting: README.txt
2、检查MySQL及相关RPM包,是否安装,如果有安装,则移除(rpm –e 名称)
[[email protected] soft]#rpm -qa | grep -i mariadb-* [[email protected] soft]# rpm -e mariadb-libs 否则有可能报错: [[email protected] soft]# rpm -ivh mysql-commercial-libs-5.7.16-1.1.el7.x86_64.rpm warning: mysql-commercial-libs-5.7.16-1.1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY error: Failed dependencies: mysql-commercial-common(x86-64) >= 5.7.9 is needed by mysql-commercial-libs-5.7.16-1.1.el7.x86_64 mariadb-libs is obsoleted by mysql-commercial-libs-5.7.16-1.1.el7.x86_64
3、安装MySQL,安装有顺序
[[email protected] soft]# rpm -ivh mysql-commercial-common-5.7.16-1.1.el7.x86_64.rpm warning: mysql-commercial-common-5.7.16-1.1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:mysql-commercial-common-5.7.16-1.################################# [100%] [[email protected] soft]# rpm -ivh --force mysql-commercial-libs-5.7.16-1.1.el7.x86_64.rpm warning: mysql-commercial-libs-5.7.16-1.1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:mysql-commercial-libs-5.7.16-1.1.################################# [100%] [[email protected] soft]# rpm -ivh mysql-commercial-client-5.7.16-1.1.el7.x86_64.rpm warning: mysql-commercial-client-5.7.16-1.1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:mysql-commercial-client-5.7.16-1.################################# [100%] 测试预安装提示如下: [[email protected] soft]# rpm -ivh --test mysql-commercial-server-5.7.16-1.1.el7.x86_64.rpm warning: mysql-commercial-server-5.7.16-1.1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY error: Failed dependencies: net-tools is needed by mysql-commercial-server-5.7.16-1.1.el7.x86_64 注:需要依赖net-tools组件 [[email protected] soft]# yum install net-tools Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: centos.ustc.edu.cn * epel: mirror01.idc.hinet.net * extras: centos.ustc.edu.cn * updates: centos.ustc.edu.cn Resolving Dependencies --> Running transaction check ---> Package net-tools.x86_64 0:2.0-0.17.20131004git.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================== Package Arch Version Repository Size ============================================================================================================================== Installing: net-tools x86_64 2.0-0.17.20131004git.el7 base 304 k Transaction Summary ============================================================================================================================== Install 1 Package Total download size: 304 k Installed size: 917 k Is this ok [y/d/N]: y Downloading packages: net-tools-2.0-0.17.20131004git.el7.x86_64.rpm | 304 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Warning: RPMDB altered outside of yum. ** Found 2 pre-existing rpmdb problem(s), ‘yum check‘ output follows: 2:postfix-2.10.1-6.el7.x86_64 has missing requires of libmysqlclient.so.18()(64bit) 2:postfix-2.10.1-6.el7.x86_64 has missing requires of libmysqlclient.so.18(libmysqlclient_18)(64bit) Installing : net-tools-2.0-0.17.20131004git.el7.x86_64 1/1 Verifying : net-tools-2.0-0.17.20131004git.el7.x86_64 1/1 Installed: net-tools.x86_64 0:2.0-0.17.20131004git.el7 Complete! [[email protected] soft]# rpm -ivh --test mysql-commercial-server-5.7.16-1.1.el7.x86_64.rpm warning: mysql-commercial-server-5.7.16-1.1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ################################# [100%] [[email protected] soft]# rpm -ivh mysql-commercial-server-5.7.16-1.1.el7.x86_64.rpm warning: mysql-commercial-server-5.7.16-1.1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:mysql-commercial-server-5.7.16-1.################################# [100%]
4、备份my.cnf,重新初始化数据库,注意mysql5.7版本初始化会随机生成一个root登录的随机密码
[[email protected] sbin]#cp /etc/my.cnf /etc/my.cnf.bak [[email protected] sbin]# /usr/sbin/mysqld --initialize --user=mysql --basedir=/data --datadir=/data 2016-11-18T05:49:59.052988Z 1 [Note] A temporary password is generated for [email protected]: T=_GTj2Wroxm (root本地登录随机密码)
5、启动服务,修改root密码
[[email protected] sbin]# systemctl start mysqld.service mysql> alter user ‘root‘@‘localhost‘ identified by ‘12345678‘; Query OK, 0 rows affected (0.00 sec)
6、安装后目录位置和内容
MySQL安装后涉及的目录如下:
目录目录中的内容
/usr/bin客户端程序和脚本
/usr/sbinMysqld服务器
/var/lib/mysql数据库的日志文件
/usr/share/info信息格式手册
/usr/share/manUnix 手册页
/usr/include/mysql包括 (标题) 的文件
/usr/lib/mysqlmysql的lib包
/usr/share/mysql杂项的支持文件,包括错误消息) 字符设置的文件,示例配置文件,SQL 数据库安装
/usr/share/sql-bench基准
默认字符集为:utf8_general_ci
mysql> show variables like ‘%collation%‘; +----------------------+-------------------+ | Variable_name | Value | +----------------------+-------------------+ | collation_connection | utf8_general_ci | | collation_database | latin1_swedish_ci | | collation_server | latin1_swedish_ci | +----------------------+-------------------+ 3 rows in set (0.01 sec)
时间: 2024-10-13 16:15:54