阿里云服务器-搭建连接MySQL
Posted Mr.zhou_Zxy
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了阿里云服务器-搭建连接MySQL相关的知识,希望对你有一定的参考价值。
mysql
1.MySQL安装
## 1. 切换到本地yum仓库
[root@hadoop ~]# cd /etc/yum.repos.d/
[root@hadoop yum.repos.d]# ll
total 8
-rw-r--r-- 1 root root 614 Apr 25 10:07 CentOS-Base.repo
-rw-r--r-- 1 root root 230 Apr 25 10:07 CentOS-Epel.repo
##2. 本地安装引导
[root@hadoop software]# yum -y localinstall mysql-community-release-el6-5.noarch.rpm
## 这里是提前下载好的MySQL
## https://dev.mysql.com/downloads/mysql/
##3. 安装
[root@hadoop yum.repos.d]# yum -y install mysql-server
##4. 启动服务
[root@hadoop yum.repos.d]# service mysqld start
##5. 初始化密码
[root@hadoop yum.repos.d]# mysqladmin -uroot password '123456'
##6. 登陆
[root@hadoop yum.repos.d]# mysql -uroot -p123456
2.远程授权
##1. 登陆
[root@hadoop yum.repos.d]# mysql -uroot -p123456
##2.查询权限
mysql> mysql> select user,host from user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+------------------+-----------+
4 rows in set (0.01 sec)
##3.修改权限
mysql> mysqle user set host = '%' where user = 'root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select user,host from user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| root | % |
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
+------------------+-----------+
4 rows in set (0.00 sec)
##4.远程授权
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
##5. 登陆
[root@hadoop yum.repos.d]# systemctl stop firewalld
3.阿里云开放3306端口
4.Navicat连接
以上是关于阿里云服务器-搭建连接MySQL的主要内容,如果未能解决你的问题,请参考以下文章