CentOS 6 下RPM方式安装MySQL5.6

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介:

1. 下载Linux对应的RPM包,如:CentOS6.7_64对应的RPM包,如下:
[root@mysql ~]# ll
总用量 113808
-rw-------. 1 root root     1434 12月 13 18:47 anaconda-ks.cfg
-rw-r--r--. 1 root root    42556 12月 13 18:47 install.log
-rw-r--r--. 1 root root    10033 12月 13 18:45 install.log.syslog
-rw-r--r--. 1 root root 23135399 12月 13 18:56 MySQL-client-5.6.25-1.linux_glibc2.5.x86_64.rpm
-rw-r--r--. 1 root root  4586217 12月 13 18:56 MySQL-devel-5.6.25-1.linux_glibc2.5.x86_64.rpm
-rw-r--r--. 1 root root 88715219 12月 13 18:56 MySQL-server-5.6.25-1.linux_glibc2.5.x86_64.rpm
2. 检查MySQL及相关RPM包,是否安装,如果有安装,则移除(rpm –e 名称)
[root@mysql ~]# rpm -qa | grep -i mysql
mysql-libs-5.1.73-5.el6_6.x86_64
[root@mysql ~]# rpm -ev mysql-libs-5.1.73-5.el6_6.x86_64 --nodeps
3. 安装MySQL
[root@mysql ~]# rpm -ivh MySQL-server-5.6.25-1.linux_glibc2.5.x86_64.rpm 
Preparing...                ########################################### [100%]
   1:MySQL-server           ########################################### [100%]
warning: user mysql does not exist - using root
warning: group mysql does not exist - using root
Support MySQL by buying support/licenses at http://shop.mysql.com
New default config file was created as /usr/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
[root@mysql ~]# rpm -ivh MySQL-devel-5.6.25-1.linux_glibc2.5.x86_64.rpm 
Preparing...                ########################################### [100%]
   1:MySQL-devel            ########################################### [100%]
[root@mysql ~]# rpm -ivh MySQL-client-5.6.25-1.linux_glibc2.5.x86_64.rpm 
Preparing...                ########################################### [100%]
   1:MySQL-client           ########################################### [100%]
4. 初始化MySQL及设置密码
[root@mysql ~]# /usr/bin/mysql_install_db             -- mysql_install_db脚本来生成帐户和相应权限许可表
WARNING: The host 'mysql' could not be looked up with /usr/bin/resolveip.
This probably means that your libc libraries are not 100 % compatible
。。省略输出。。
WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
[root@mysql ~]# service mysql start
Starting MySQL. SUCCESS! 
[root@mysql ~]# cat /root/.mysql_secret    --查看root账号密码
# The random password set for the root user at Tue Dec 13 18:59:06 2016 (local time): 7MhtyX3aZEl9OUf8
[root@mysql ~]# mysql -uroot -p
Enter password:               --(此处复制粘贴 7MhtyX3aZEl9OUf8)
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.2
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
说明:  出现mysql>   表示一切顺利成功。
mysql> SET PASSWORD = PASSWORD('123456');   --设置密码为123456
5. 允许远程登陆
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select host,user,password from user;
+-----------+------+-------------------------------------------+
| host      | user | password                                  |
+-----------+------+-------------------------------------------+
| localhost | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| mysql     | root | *6D95CDA252C85345E8BC1C4168E962D3949C30F9 |
| 127.0.0.1 | root | *6D95CDA252C85345E8BC1C4168E962D3949C30F9 |
| ::1       | root | *6D95CDA252C85345E8BC1C4168E962D3949C30F9 |
+-----------+------+-------------------------------------------+
4 rows in set (0.00 sec)
mysql> update user set password=password('123456') where user='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 4  Changed: 3  Warnings: 0
mysql> update user set host='%' where user='root' and host='localhost';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
6. 设置开机自启动
[root@mysql ~]# chkconfig mysql on
[root@mysql ~]# chkconfig --list | grep mysql
mysql           0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
7.  MySQL的默认安装位置
/var/lib/mysql/               #数据库目录
/usr/share/mysql              #配置文件目录
/usr/bin                     #相关命令目录
/etc/init.d/mysql              #启动脚本
8.  更改MySQL目录与字符集
[root@mysql01 /]# cd /
[root@mysql01 /]# mkdir data    #建立data目录
[root@mysql01 /]#  service mysql stop 
Shutting down MySQL....                                    [  OK  ]
[root@mysql01 /]# mv /var/lib/mysql  /data   #把/var/lib/mysql整个目录移到/home/data
[root@mysql01 /]#  mkdir -p /data/mysql/binarylog
[root@mysql01 /]# chown -R mysql:mysql /data/mysql
 
如果/etc/目录下没有my.cnf配置文件,请到/usr/share/mysql/下找到*.cnf文件,拷贝其中一个到/etc/并改名为my.cnf中
[root@mysql ~]# cp /usr/share/mysql/my-default.cnf /etc/my.cnf    --修改配置文件位置
配置/etc/my.cnf文件,修改数据存放路径、mysql.sock路径以及默认编码utf-8.
[root@mysql01 /]# cat /etc/my.cnf
[client]
password = 123456
port = 3306
default-character-set = utf8
[mysqld]
port = 3306
socket = /data/mysql/mysql.sock
character_set_server = utf8
character_set_client = utf8
collation-server=utf8_general_ci
lower_case_table_names = 1
max_connections = 1000
datadir = /data/mysql/
log_bin = /data/mysql/binarylog/binlog 
[mysql]
default-character-set = utf8
socket  = /data/mysql/mysql.sock 

查看字符集
show variables like '%collation%';
show variables like '%char%';

9. 重新启动MySQL服务

[root@mysql ~]# service mysql restart
Shutting down MySQL.. SUCCESS! 
Starting MySQL. SUCCESS! 
OK  一切成功

文章可以转载,必须以链接形式标明出处。

本文转自 张冲andy 博客园博客,原文链接:  http://www.cnblogs.com/andy6/p/6169415.html  ,如需转载请自行联系原作者

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
2天前
|
SQL 存储 关系型数据库
MySQL Cluster集群安装及使用
MySQL Cluster集群安装及使用
|
19小时前
|
关系型数据库 MySQL 数据安全/隐私保护
安装mysql和远程连接
安装mysql和远程连接
6 0
|
23小时前
|
关系型数据库 MySQL Java
Linux 安装 JDK、MySQL、Tomcat(图文并茂)
Linux 安装 JDK、MySQL、Tomcat(图文并茂)
12 2
|
2天前
|
Linux
centos 6.5安装yum
centos 6.5安装yum
17 0
|
2天前
|
运维 网络协议 Linux
【运维系列】Centos7安装并配置PXE服务
PXE是Intel开发的预启动执行环境,允许工作站通过网络从远程服务器启动操作系统。它依赖DHCP分配IP,DNS服务分配主机名,TFTP提供引导程序,HTTP/FTP/NFS提供安装源。要部署PXE服务器,需关闭selinux和防火墙,安装dhcpd、httpd、tftp、xinetd及相关服务,配置引导文件和Centos7安装源。最后,通过syslinux安装引导文件,并创建pxelinux.cfg/default配置文件来定义启动参数。
13 0
|
2天前
|
运维 网络协议 Linux
【运维系列】Centos7安装并配置postfix服务
安装CentOS7的Postfix和Dovecot,配置Postfix的`main.cf`文件,包括修改完全域名、允许所有IP、启用邮箱等。然后,配置Dovecot的多个配置文件以启用auth服务和调整相关设置。重启Postfix和Dovecot,设置开机自启,并关闭防火墙进行测试。最后,创建邮箱账户并在Windows邮箱客户端中添加账户设置。
10 0
|
2天前
|
关系型数据库 MySQL Windows
windows安装MySQL5.7教程
windows安装MySQL5.7教程
9 0
|
2天前
|
Linux 网络安全
Centos6.5安装并配置NFS服务
该内容描述了在Linux系统中设置NFS服务的步骤。首先挂载yum源,然后安装NFS服务,并编辑配置文件。接着,重启rpcbind和NFS服务,可能需要重复此过程以解决初始可能出现的问题。此外,关闭防火墙策略,并再次重启服务。最终,根目录被共享,特定IP网段被允许访问。
9 0
|
18天前
|
关系型数据库 MySQL 数据库
mysql卸载、下载、安装(window版本)
mysql卸载、下载、安装(window版本)
|
1月前
|
关系型数据库 MySQL 数据库
rds安装数据库客户端工具
安装阿里云RDS的数据库客户端涉及在本地安装对应类型(如MySQL、PostgreSQL)的客户端工具。对于MySQL,可选择MySQL Command-Line Client或图形化工具如Navicat,安装后输入RDS实例的连接参数进行连接。对于PostgreSQL,可以使用`psql`命令行工具或图形化客户端如PgAdmin。首先从阿里云控制台获取连接信息,然后按照官方文档安装客户端,最后配置客户端连接以确保遵循安全指引。
86 1