Cong Zero started to configure MySQL on CentOS8 and use navicat to connect

Configure MySQL on Linux

foreword

I am a novice in Linux. This article records the process of configuring MySQL on centos.
Please understand the shortcomings

  • Before installing and configuring a software, be sure to pay attention to 版本the sum of the software 环境,
    otherwise errors may occur

reference documents

The following are the documents referenced in this article,

This article is just to integrate these documents,
you can directly read the tutorials of these documents

[1. Install a virtual machine on Linux] ( The latest VMware virtual machine installs Linux system-CentOS (detailed tutorial) - Fu Zongle - Blog Garden (cnblogs.com) ) [
2. Install centos8 ] ( Technology|CentOS 8 installation diagram (linux.cn )

[3. Configure MySQL on centos8]( Linux (centos8) to install MySQL 8 database (detailed tutorial with graphics and text) - Cloud + Community - Tencent Cloud (tencent.com) )

[4. Configure bridged network connection]( (7 messages) Centos8 uses bridged mode to connect to the network_But Xi Liunian's blog-CSDN blog_centos8 bridge )

对以上文档作者表示感谢

Experimental goal

  • Install centOS8 on the virtual machine
  • Install MySQL database on centOS8
  • Use vavicat on windows to access the virtual machine data database

Environment introduction

  • centOS8

  • MySQL8.0

  • navicat15

Experimental procedure

One: Install and configure centOS8

VMware creates a virtual machine

There is no special marked process, just choose the default

  1. Click to create a virtual machine

insert image description here

  1. Click on Customize Advanced
  2. Choose to install the operating system later

insert image description here

  1. Choose the version to install

insert image description here

  1. set 虚拟机名称and存储位置

insert image description here

  1. Set the number of processors

insert image description here

  1. Configure virtual machine memory

insert image description here

  1. Choose network mode

insert image description here

  1. choose default

insert image description here

  1. choose default

insert image description here

  1. Select disk configuration

insert image description here

  1. Allocate space on disk

insert image description here

  1. select location

insert image description here

  1. Choose custom accessories here

insert image description here

  1. Configuration image file

insert image description here

  1. Just click to finish

insert image description here

CentOS8 system configuration

  1. Click to start the virtual machine

insert image description here

  1. Start to install the system

insert image description here

  1. Wait for a while... Select Chinese and click to continue

insert image description here

  1. set root password

insert image description here

Click Finish when finished

insert image description here

  1. choose安装类型

insert image description here

insert image description here

  1. set time and date

insert image description here

find asia shanghai

insert image description here

  1. Install Destination in One Click

insert image description here

After entering, wait a moment, just click Finish

insert image description here

  1. Finally click to start the installation等待一段时间~~

insert image description here

  1. Restart the system after the installation is complete

insert image description here

  1. After reboot click许可信息

insert image description here

Tick ​​I agree to the agreement and click Finish
insert image description here

  1. create another user

insert image description here

After entering the username and password, click Finish

insert image description here

Finally click to finish the configuration
insert image description here

  1. Choose Chinese, and then go to the next step

insert image description here

Go to this interface and click to start using

insert image description here

insert image description here

Configure Bridged Networking

The reason for using bridge mode is that I can't use nat模式the host to ping the virtual machine

  1. Check if the network virtual editor is桥接模式

insert image description here

Note: After selecting bridge mode, you need to select a network card具体就是你上网的那个网卡

  1. cmdOpen Enter on Windows ipconfigto view local network information

insert image description here

Note: The information in the red box will be used later

  1. Check the network card of the virtual machine to make sure it is in bridge mode

insert image description here

Configuring the network is also a complex environment. You must know the current computer network environment
. With my current network environment, the configuration in bridge mode is as follows

IP address subnet mask gateway dns server
the host 192.168.254.244 255.255.255.0 192.168.254.71
virtual machine (optional) 192.168.254.2 ~~ 192.168.254.254 cannot be 192.168.254.244 255.255.255.0 192.168.254.71 114.114.114.114
virtual machine (actual) 192.168.254.200 255.255.255.0 192.168.254.71 114.114.114.114
The ip address needs to be in the same address segment unanimous unanimous this one
  1. Configure the network card information of CentOS8

Enter the virtual machine command line, enter the following command to switch to the administrator

su root

Enter the following command this ifcfg-ens33time 33is sometimes32

# 进入文件夹
cd /etc/sysconfig/network-scripts
# 使用vim操作文件
vim ifcfg-ens33

Modify the following parameters here is static ipDHCP有时候会有问题

Because the ip address I use 校园网will change, and I may have to manually change it later

# 如为静态ip则需要配置以下几个属性
# 是否开机启动
ONBOOT=yes
# 静态IP 和主机在同一地址段
IPADDR=xxx.xxx.xxx.xxx
# 子网掩码
NETMASK=255.255.255.0
# 网关地址 和主机一致
GATEWAY=192.168.1.1
# DNS地址
DNS1=114.114.114.114

My configuration is as follows
insert image description here

#注:vim 使用 i 进入编辑模式
#   先按esc 在输入 :wq 即可保存退出

After saving the configuration modification, use to nmcli c reload ens33restart the network card service, and use ip addrto view the ip

insert image description here

  1. connection test

Ping Baidu, there is a response

insert image description here

The host pings the virtual machine

insert image description here

The virtual machine pings the host

insert image description here

这三个地址都能ping通,网络工作就准备完善了

Two: Install MySQL on CentOS8

  1. Download and install MySQ official Yum Repository
wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
  1. Then install the repo
rpm -ivh mysql80-community-release-el7-1.noarch.rpm
  1. Then start installing the MySQL server.
yum install mysql-server

这个过程需要一段时间,其间需要多次输入y,以继续安装

installation started

insert image description here

end of installation

insert image description here

  1. start mysql
systemctl start mysqld.service 
  1. Viewing the MySQL running status active( running )indicates that the operation is successful
systemctl status mysqld.service

insert image description here

  1. enter the database
mysql -uroot -p

insert image description here

Successfully entered the interface

insert image description here

  1. change initial password
ALTER USER 'root'@'localhost' IDENTIFIED BY '你的新密码';

insert image description here

  1. Enter show databases;view database

insert image description here

Since then, the MySQL database has been successfully installed

Three: Use navicat to connect to MySQL on centos8

  1. Use ip addrto view the virtual machine IP address as192.168.254.200

insert image description here

  1. Use navicat to test the connection

insert image description here

But now the connection will fail, and some configuration is required

insert image description here

  1. Open port 3306
firewall-cmd --permanent --zone=public --add-port=3306/tcp
  1. refresh port
firewall-cmd --reload
  1. The following prompt will appear when connecting again, because the user does not have the remote login permission

insert image description here

  1. Login to MySQL
mysql -u root -p
# 在输入下面命令,查看用户表
use mysql;
select host, user, authentication_string, plugin from user;

insert image description here

It can be seen that the host corresponding to the user is localhost, not %, so it cannot be connected

  1. Authorize the root user to log in remotely
# 授权权限
update user set host='%' where user = 'root';
# 刷新权限
flush privileges;
  1. Use navicat to test the connection again, the connection is successful

insert image description here

Four: Add a data test

  • New query in navicat
#创建数据库
create database db_test;
#切换数据库
use db_test;
#创建学生表
create table students(sname char(10),sage int);
#插入一条数据
insert into students values( "Jake",18 );
  • View in centos8
#切换数据库
use db_test;
#查询数据
select * from students;

insert image description here

Since then, the project experiment has been completed;

Guess you like

Origin blog.csdn.net/weixin_44815800/article/details/120911938