centOS7环境在线安装mysql

6 篇文章 1 订阅

###第一步检查是否已安装
1:检查是否本地已经安装了mysql

rpm -qa | grep mysql

2:卸载以前的mysql

rpm -e 已经存在的MySQL全名

###开始安装
保持联网状态下,现在执行下面命令

yum install mysql

继续执行下面命令:

yum install mysql-devel

执行命令过程中遇到类似这样的都是输入y,继续

总计:8.9 M
总下载量:3.4 M
Is this ok [y/d/N]: 

然后执行下面3个命令:

# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
# rpm -ivh mysql-community-release-el7-5.noarch.rpm
# yum install mysql-community-server

执行完,重启mysql服务。

# service mysqld restart

然后即可登录mysql,初始登录没有密码

[root@slave1 ~]# service mysqld restart
Redirecting to /bin/systemctl restart  mysqld.service
[root@slave1 ~]#  mysql -u root 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.40 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

初次登录设置一下密码,设置为123456

mysql> set password for 'root'@'localhost' =password('123456');
Query OK, 0 rows affected (0.02 sec)

退户登录

mysql> exit
Bye
[root@slave1 ~]# 

###配置mysql

# vim /etc/my.cnf

在最后面添加下面内容

[mysql]
default-character-set =utf8

###配置mysql远程链接
设置远程访问账号:grant all privileges on . to 远程访问用户名@’%’ identified by ‘用户密码’;

mysql> grant all privileges on *.* to root@'%' identified by '123456';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> 

配置完即可通过navicat工具远程连接上

这里写图片描述
如果还是连接不上,估计是防火墙问题,本文不做详细介绍了,目前没有这样的环境作为说明
也可以试试下面命令解决连接数据库问题

# 以下命令,需要在mysql的客户端下执行。设置远程访问权限
> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
# 刷新权限
>FLUSH PRIVILEGES;
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值