安装MySQL

使用YUM安装

MySQL社区版

官方源 mysql-community.repo

[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/6/$basearch/
enabled=1
gpgcheck=0
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/6/$basearch/
enabled=1
gpgcheck=0
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/6/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

MySQL社区版个人源

(小樱[1265578519@qq.com]

个人搭建,国内访问较快,不保证绝对安全)

https://github.com/1265578519/repo/blob/master/CentOS/mysql-community.repo

[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=http://repo.itzmx.com/yum/mysql-connectors-community/el/6/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[mysql-tools-community]
name=MySQL Tools Community
baseurl=http://repo.itzmx.com/yum/mysql-tools-community/el/6/$basearch/
enabled=1
gpgcheck=0
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.itzmx.com/yum/mysql-5.5-community/el/6/$basearch/
enabled=0
gpgcheck=0
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.itzmx.com/yum/mysql-5.6-community/el/6/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

# Note: MySQL 5.7 is currently in development. For use at your own risk.
# Please read with sub pages: https://dev.mysql.com/doc/relnotes/mysql/5.7/en/
[mysql57-community-dmr]
name=MySQL 5.7 Community Server Development Milestone Release
baseurl=http://repo.itzmx.com/yum/mysql-5.7-community/el/6/$basearch/
enabled=0
gpgcheck=0
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

centos 7 下安装 mysql-community-server

#找到yum源,并安装:
rpm -ivh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
#执行yum安装:
yum search mysql-community-server
yum info mysql-community-server
yum install -y mysql-community-server
# Step 2 — Starting MySQL
# We'll start the daemon with the following command:
sudo systemctl start mysqld
# systemctl doesn't display the outcome of all service management commands, so to be sure we succeeded, we'll use the following command:
sudo systemctl status mysqld
#第一次登陆使用密码
vi /var/log/mysqld.log里面找

常见错误

【错误过程】:MySQL从5.1升级至5.5后在调用存储过程时报出“Cannot load from mysql.proc. The table is probably corrupted。”
【造成原因】:MySQL升级完成后未对相关数据库执行升级.
【解决办法】:在命令行中执行mysql_upgrade -uroot -p 即可~

启动命令

/etc/init.d/mysqld start