外网配置
我的虚拟机配置ping的时候就是桥接模式
但是现在ping www.baidu.com
显示网络不可达
解决 ping www.baidu.com
vi /etc/resolv.conf
在下面添加 nameserver 61.128.128.68
nameserver 61.128.128.68
*nmcli connection modify enp0s3 *
测试 ping成功
开始搭建MySQL
关闭防火墙
更新yum源
yum update
东西有点多
下载MySQL
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
初始化数据库
rpm -ivh mysql-community-release-el7-5.noarch.rpm
继续更新yum包
yum update
安装MySQL
安装数据库并启动数据库
yum install mysql-server
systemctl start mysqld
配置脚本文件
mysql_secure_installation
输入root密码,初始为null,回车就可以设置root密码了,如果有y/n问题,都输y
登录MySQL
输入刚刚设置的密码
mysql -u root -p
查看MySQL编码
其中datebase和server的编码为latin1,现修改为utf8
show variables like ‘%character%’;
将my-default.cnf 拷贝到 /etc/my.cnf
cp /usr/share/doc/mysql-community-server-5.6.31/my-default.cnf /etc/my.cnf
编辑/usr/my.cnf在client下增加
default-character-set = utf8
编辑/usr/my.cnf在[mysqld]下增加
character_set_server = utf8
重启MySql服务
systemctl restart mysql.service
重现连接mysql并查看编码,可看到已更改
mysql -u root –p
mysql>show variables like ‘%character%’;
mysql>exit
远程登录
workbench 下载 选择windows 64位版本
地址:https://cdn.mysql.com//Downloads/MySQLGUITools/mysql-workbench-community-8.0.18-winx64.msi
登录
输入刚刚设好的密码
mysql -u root –p
允许远程登录
GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘root’;
#这里意思是允许任何ip以root用户以密码root登录
FLUSH PRIVILEGES;
开放3306端口
查看防火墙状态
systemctl status firewalld
这里防火墙是关闭的,现将它开启
systemctl start firewalld
加入3306端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
重启MySQL
powershell
service restart mysqld
使用workbench连接MySQL
点击加号
输入信息 Hostname: 172.20.10.6
连接成功!!!