手记

centos7安装mysql5.6并开启远程访问

首先安装mysql5.6的rpm

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

5.7的源:http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm

安装mysql

yum install mysql-community-server

运行mysqld

systemctl start mysqld

查看mysqld的运行状态和一些初始化的提示

systemctl status mysqld

可以看到设置默认密码的几种方式

/usr/bin/mysqladmin -u root password 'new-password'

开机启动mysqld

systemctl enable mysqld

授权远程访问

mysql> use mysql;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> grant all privileges on . to root@'%' identified by "password";

Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

打开3306端口的访问

firewall-cmd --add-port=3306/tcp --permanent

firewall-cmd --reload

5人推荐
随时随地看视频
慕课网APP