美文网首页
centos6.8 yum安装mysql 5.6

centos6.8 yum安装mysql 5.6

作者: 迈小步 | 来源:发表于2018-07-29 16:56 被阅读0次

一、检查系统是否安装其他版本的MYSQL数据

#yum list installed | grep mysql

#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

安装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

如下(少补):

[mysqld]

character-set-server=utf8

collation-server=utf8_general_ci

sql_mode='NO_ENGINE_SUBSTITUTION'

[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 -uroot -p

mysql> show variables like 'character%';

+--------------------------+----------------------------+

| Variable_name | Value |

+--------------------------+----------------------------+

| character_set_client | utf8 |

| character_set_connection | utf8 |

| character_set_database | utf8 |

| character_set_filesystem | binary |

| character_set_results | utf8 |

| character_set_server | utf8 |

| character_set_system | utf8 |

| character_sets_dir | /usr/share/mysql/charsets/ |

+--------------------------+----------------------------+

rows in set (0.00 sec)

上面这些也可以写成脚本,不用每次都重复这些步骤,也记不住,一键安装才是大家需要的。

我提供了下载mysql5.6安装包包和执行脚本,需要注意的是,包和脚本放在Linux中/opt/softpackage文件夹下

相关文章

网友评论

      本文标题:centos6.8 yum安装mysql 5.6

      本文链接:https://www.haomeiwen.com/subject/ipxtvftx.html