linux篇之安装MySQL及远程连接

来源:互联网 发布:mac地址查询设备 编辑:程序博客网 时间:2024/06/07 11:28

今天在阿里云ESC中配置mysql环境遇到了一些坑,安装倒是很顺利,但是在使用navicat远程连接ESC中安装好的mysql耗费了挺多时间。

1.linux中mysql操作

1.1#######安装rpm包
rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
1.2这时查看当前可用的mysql安装资源:
yum repolist enabled | grep “mysql.-community.
1.3直接安装
yum -y install mysql-community-server

2 MySQL安装完成后,进行相关配置
安装完MySQL后,需要进行一些基础配置工作:
2.1#######安装成功后,将其加入开机启动
[root@typecodes ~]# systemctl enable mysqld

2.2#######启动mysql服务进程[root@typecodes ~]# systemctl start mysqld2.3#######配置mysql(设置密码等)[root@typecodes ~]# mysql_secure_installation

3 打开mysql
重启mysql:systemctl restart mysqld
隐式密码登录: mysql -uroot -p
mysql> show databases; //显示数据库
mysql> use songtest; //显示songtest表
mysql> flush provileges; //刷新系统权限
mysql> quit //退出(或者exit)

4.在远程连接数据库
这里写图片描述
除了选择常规还要选择ssh通道,注意一定要在安全组开放3306端口!!
这里写图片描述

连接时可能会显示 Access denied for user ‘root’@’xxx.xxx.xxx.xxx’ (using password: YES) 的错误(这个地方鼓捣了很久才解决)
这里写图片描述
检查常规中密码是否出错,如果没有出错那就是阿里ESC中mysql有访问权限

【解决办法】
1. 先登录
mysql -uroot -p
Enter password:
2. 执行授权命令
mysql> grant all privileges on . to root@’%’ identified by ‘123456’;
Query OK, 0 rows affected (0.07 sec)
3. 退出再试
mysql> quit
Bye

原创粉丝点击