centos6 yum安装mysql 5.6 (完整版)

使用源代码编译安装mysql还是比较麻烦,一般来说设备安装时请网络同事临时开通linux上网,通过yum网络实现快速安装,或配置yum仓库进行内网统一安装。

通过网络快速安装过程如下

一、检查系统是否安装其他版本的MYSQL数据,有的话干掉老版本数据库
#yum list installed | grep mysql
mysql-libs.x86_64      5.1.73-5.el6_6   @anaconda-CentOS-201508042137.x86_64/6.7
#yum -y remove mysql-libs.x86_64
二.安装及配置
# wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
# rpm -ivh mysql-community-release-el6-5.noarch.rpm
# yum repolist all | grep mysql
安装成功后在/etc/yum.repos.d/下会多出几个mysql的yum源的配置
下面安装MYSQL数据库,这个过程比较久
# yum install mysql-community-server -y

三。设置为开机启动(2、3、4都是on代表开机自动启动)
# chkconfig --list | grep mysqld
# chkconfig mysqld on

四、设置远程root
启动mysql
# service mysqld start
设置root密码
# mysql_secure_installation
登陆root账号
# mysql -uroot -p 
建立远程root用户
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '你设置的密码' WITH GRANT OPTION;
mysql> flush privileges;

 

五、设置utf-8编码

查看mysql原本编码:
mysql> show variables like 'character%';
# vi /etc/my.cnf
[mysql]
default-character-set = utf8
[mysql.server]
default-character-set = utf8
[mysqld_safe]
default-character-set = utf8
[client]
default-character-set = utf8

重启mysql

# service mysqld restart
重新登录mysql

注:yum安装mysql唯一有个问题,就是下载速度太慢,所以生产环境下,过去常采用rpm方式安装,然后用脚本SCP 或 ansible 到其他机器,一键远程安装



posted @ 2019-06-08 08:45  micfox的架构师之路  阅读(3547)  评论(0编辑  收藏  举报