1、添加MySQL Yum Repository(RPM包)。
a、下载地址在:.
3、如何修改配置文件,选择自己想要安装的版本。
编辑 /etc/yum.repos.d/mysql-community.repo
默认是这样的(需要将enabled设置为0) 为0的意思就是禁用。
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
然后修改5.6版本的 (enabled设置为1)
# 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=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
4、安装MySQL
shell> sudo yum install mysql-community-server
5、相关服务
shell> sudo service mysqld start 启动服务
shell> sudo service mysqld restart 重启
shell> sudo service mysqld stop 停止
6、启动后修改密码以及设置远程登录
mysqladmin -u root password newpass 修改密码
设置 ROOT 远程连接 update user set host = '%' where user='root';
7、登陆问题:
mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: YES)'
1:停止mysql服务: service mysqld stop
2:执行命令:
a: mysqld_safe --skip-grant-tables & mysql -uroot -p 回车进入
b: use mysql; 切换到mysql数据库
c: update user set password=PASSWORD("newpass")where user="root";
更改密码为 newpass , 这里一定上PASSWORD("xxx") ,PASSWORD是一个函数
d: flush privileges; 更新权限
e: quit; 退出
3:重启mysql服务:service mysqld restart
4:链接数据库:mysql -uroot -p 新密码
8、CentOS7中关闭selinux
http://www.centoscn.com/CentOS/config/2015/0618/5681.html
编辑配置文件
chown -R mysql:mysql /data/mysql