linux安装MySQL

一.部署OpenEuler

1.安装os

[root@localhost ~]# echo 123456 | passwd --stdin root
更改用户 root 的密码 。
passwd:所有的身份验证令牌已经成功更新。
[root@localhost ~]# firewall-cmd --state
running
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# firewall-cmd --state
not running
[root@localhost ~]# getenforce
Enforcing
[root@localhost ~]# sed -i '/^SELINUX=/ c SELINUX=disabled' /etc/selinux/config
[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce
Permissive
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mv openEuler.repo openEuler.repo.bak
[root@localhost yum.repos.d]# vi /etc/yum.repos.d/openEuler.repo
[root@localhost ~]# yum install wget net-tools tree psmisc bash-completion vim -y

2.建立连接

二.安装MySQL 8.0 使用yum

1.查询版本

[root@localhost ~]# yum list | grep -i ^mysql
mysql.x86_64                                            8.0.38-1.oe2203sp4                                   openEuler-update
mysql-common.x86_64                                     8.0.38-1.oe2203sp4                                   openEuler-update
mysql-config.x86_64                                     8.0.38-1.oe2203sp4                                   openEuler-update
mysql-connector-java.noarch                             1:8.0.30-1.oe2203sp4                                 openEuler-everything
mysql-debuginfo.x86_64                                  8.0.38-1.oe2203sp4                                   openEuler-update
mysql-debugsource.x86_64                                8.0.38-1.oe2203sp4                                   openEuler-update
mysql-devel.x86_64                                      8.0.38-1.oe2203sp4                                   openEuler-update
mysql-errmsg.x86_64                                     8.0.38-1.oe2203sp4                                   openEuler-update
mysql-help.x86_64                                       8.0.38-1.oe2203sp4                                   openEuler-update
mysql-libs.x86_64                                       8.0.38-1.oe2203sp4                                   openEuler-update
mysql-selinux.noarch                                    1.0.0-2.oe2203sp4                                    openEuler-everything
mysql-server.x86_64                                     8.0.38-1.oe2203sp4                                   openEuler-update
mysql-test.x86_64                                       8.0.38-1.oe2203sp4                                   openEuler-update
mysql5.x86_64                                           5.7.44-1.oe2203sp4                                   openEuler-everything
mysql5-common.x86_64                                    5.7.44-1.oe2203sp4                                   openEuler-everything
mysql5-devel.x86_64                                     5.7.44-1.oe2203sp4                                   openEuler-everything
mysql5-embedded.x86_64                                  5.7.44-1.oe2203sp4                                   openEuler-everything
mysql5-embedded-devel.x86_64                            5.7.44-1.oe2203sp4                                   openEuler-everything
mysql5-errmsg.x86_64                                    5.7.44-1.oe2203sp4                                   openEuler-everything
mysql5-libs.x86_64                                      5.7.44-1.oe2203sp4                                   openEuler-everything
mysql5-server.x86_64                                    5.7.44-1.oe2203sp4                                   openEuler-everything
mysql5-test.x86_64                                      5.7.44-1.oe2203sp4                                   openEuler-everything

2.安装 MySQL 8.0.38

[root@localhost ~]# yum install -y mysql-server

3.启动MySQL

[root@localhost ~]# systemctl enable --now mysqld

# 检查启动成功与否?
# 方法1: 查看端口 3306
[root@localhost ~]# netstat -lnupt | grep :3306
tcp6       0      0 :::33060                :::*                    LISTEN      1929/mysqld
tcp6       0      0 :::3306                 :::*                    LISTEN      1929/mysqld

# 方法2: 查看服务状态
[root@localhost ~]# systemctl status mysqld
● mysqld.service - MySQL 8.0 database server
     Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset:>
     Active: active (running) since Thu 2024-09-12 18:33:28 CST; 21s ago
    Process: 1833 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=>
    Process: 1855 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (cod>
   Main PID: 1929 (mysqld)
     Status: "Server is operational"
      Tasks: 38 (limit: 21404)
     Memory: 466.2M
     CGroup: /system.slice/mysqld.service
             └─ 1929 /usr/libexec/mysqld --basedir=/usr

9月 12 18:33:23 localhost.localdomain systemd[1]: Starting MySQL 8.0 database server>
9月 12 18:33:23 localhost.localdomain mysql-prepare-db-dir[1855]: Initializing MySQL>
9月 12 18:33:28 localhost.localdomain systemd[1]: Started MySQL 8.0 database server.

# 方法3: 查看进程
[root@localhost ~]# ps -ef | grep mysqld
mysql       1929       1  2 18:33 ?        00:00:01 /usr/libexec/mysqld --basedir=/usr
root        1980    1609  0 18:34 pts/0    00:00:00 grep --color=auto mysqld

# 方法4: 通过 lsof 反查 端口
[root@localhost ~]# yum install lsof -y
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                             1/1
  Installing       : lsof-4.96.4-4.oe2203sp4.x86_64                              1/1
  Verifying        : lsof-4.96.4-4.oe2203sp4.x86_64                              1/1
Complete!

4.测试登录

命令:
本地登录: mysql -uroot -p'密码'

秘密如何获取?
[root@localhost ~]# grep password /var/log/mysql/mysqld.log
2024-09-12T10:33:25.121260Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
[root@localhost ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.38 Source distribution

Copyright (c) 2000, 2024, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> \q
Bye
[root@localhost ~]# mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.38 Source distribution

Copyright (c) 2000, 2024, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> \q
Bye

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值