MySQL
CentOS6.8
VirtualBox
一、yum安装
进入https://dev.mysql.com/downloads/repo/yum/
MySQL RPM
直接下载
得到下载地址,在CentOS内执行命令:
wget https://dev.mysql.com/get/mysql57-community-release-el6-11.noarch.rpm
sudo rpm -Uvh mysql57-community-release-el6-11.noarch.rpm
结果如下:
MySQL RPM下载执行结果
# ls /etc/yum.repos.d/,多了两个MySQL的源:
MySQL数据源
安装MySQL
yum install mysql-community-server
二、MySQL配置
启动MySQL服务
service mysqld start
启动MySQL
获取root用户的密码:
grep 'temporary password' /var/log/mysqld.log
root用户密码
登录并修改密码
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPwd4!';
commit;
三、开启远程连接
1、设置iptables
vi /etc/sysconfig/iptables
增加
-A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT
重启iptables
1)、重启后永久性生效:
开启:chkconfig iptables on
关闭:chkconfig iptables off
2)、即时生效,重启后失效:
开启:service iptables start
关闭:service iptables stop
2、开启MySQL的远程连接
mysql -u root -p
use mysql;
update user set host ='%' where user ='root';
flush privileges;
宿主机通过客户端访问MySQL成功。
四、MySQL开机自启动
vi /etc/rc.local
添加
service mysqld start