Centos 安装mysql 5.5
一:下载mysql官方repo
yum -y install https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
二:修改镜像源
官方提供了多个版本的镜像源地址,根据自身需求进行开启和关闭,此文中打开mysql 5.5的enabled,修改为1
[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[mysql-tools-community]
name=MySQL Tools Community
baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
# Enable to use MySQL 5.5
[mysql55-community]
name=MySQL 5.5 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
# Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
三:安装
yum -y install mysql-server mysql-client
四:配置my.cnf
只增加了简单配置,具体的优化后面有时间再搞
server-id = 1
port=3306
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-bin=/var/lib/mysql/mysql-bin
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Recommended in standard MySQL setup
#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
#是否对sql语句大小写敏感,默认值为0,1表示不敏感
lower_case_table_names = 1
#最大连接数
max_connections = 1000
#最大错误连接数
max_connect_errors = 1000
#skip-grant-tables
设置密码
在my.cnf中打开skip-gant-tables后免密码进入数据库
# 如果要设置成外网也可以连接的话把localhost换成 %
> grant all privileges on *.* to 'root'@'localost' identified by 'password' with grant option;
> flush privileges
> exit
注释掉skip…这一行,重启服务器,登录验证