您的位置:首页 > 运维架构 > Linux

Linux系统基于Centos7安装mysql5.6数据库

2019-04-04 01:15 567 查看
版权声明:本文为博主原创文章,未经博主允许不得私自转载。 https://blog.csdn.net/QingHe97/article/details/89008799

前言

“鸟欲高飞先振翅,人求上进先读书。”

正文

1.下载rpm包
rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

2.查看当前可用的mysql安装资源
yum repolist enabled | grep “mysql.-community.”

3.Yum安装
yum -y install mysql-community-server

4.启动mysql
service mysqld start 如果启动mysql步骤出现下列错误
Redirecting to /bin/systemctl restart mysqld.service
使用如下命令操作mysql:
systemctl restart mysqld.service 重启
systemctl start mysqld.service 开启
systemctl stop mysqld.service 停止

5.查看运行状态
service mysqld status

6.设置密码
mysql_secure_installation 按回车

出现 Enter current password for root (enter for none): 按回车
Set root password? [Y/n] y 设置root账号密码
New password:输入新密码
Re-enter new password:再次输入
Remove anonymous users? [Y/n] Y 删除匿名用户
Disallow root login remotely? [Y/n] n 禁止远程登录
Remove test database and access to it? [Y/n] n 删除test数据库
Reload privilege tables now? [Y/n] y 刷新权限

7.关闭防火墙
systemctl stop firewalld.service

8.开启远程访问(此步骤需要先 mysql -u root -p root 登录mysql数据库后才能执行操作)
GRANT ALL PRIVILEGES ON . TO ‘root’@’%'IDENTIFIED BY ‘root’ WITH GRANT OPTION;

完成以上步骤你就可以开始远程连接Linux系统的mysql数据库了
打开windows的sqlyog 新建连接,输入你Linux的ip地址(打开终端输入ifconfig就能看到),账号密码,端口默认3306,然后测试连接。成功会弹出 connection succeefull … 的消息

注意:
每次远程连接Linux的mysql数据库都需要先开启mysql服务,然后再关闭防火墙,再登陆mysql数据库,再授权远程访问,然后回到windows,操作sqlyog才即可连接。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: