首页 > 数据库 >安装 mysql 8-yum

安装 mysql 8-yum

时间:2024-03-29 21:35:35浏览次数:24  
标签:8.0 x86 mysql server yum MySQL 64 安装

Operating System: Alibaba Cloud Linux 3 (Soaring Falcon)

Arch: x86_64

mysql-8.0.32

---

 

序章

再安装一次 MySQL,这次是在 类CentOS 的 Alibaba Cloud Linux 3 系统上进行,使用 yum 安装。

 

安装步骤

说明,全程使用 root 账号安装(存在风险)。

 

yum 搜索

# yum search mysql

Last metadata expiration check: 0:17:11 ago on Mon 18 Mar 2024 10:01:02 AM CST.
=============================================================================== Name & Summary Matched: mysql ===============================================================================
mysql.x86_64 : MySQL client programs and shared libraries
MySQL-zrm.noarch : MySQL backup manager
anope-mysql.x86_64 : MariaDB/MySQL modules for Anope IRC services

……省略……

mysql-common.x86_64 : The shared files required for MySQL server and client
mysql-devel.x86_64 : Files for development of MySQL applications
mysql-errmsg.x86_64 : The error messages files required by MySQL server
mysql-libs.x86_64 : The shared libraries required for MySQL clients
mysql-mmm.noarch : Multi-Master Replication Manager for MySQL
mysql-selinux.noarch : SELinux policy modules for MySQL and MariaDB packages
mysql-server.x86_64 : The MySQL server and related files
mysql-test.x86_64 : The test suite distributed with MySQL

……省略……

查看信息:

# yum info mysql-common.x86_64

Last metadata expiration check: 0:35:47 ago on Mon 18 Mar 2024 10:01:02 AM CST.
Available Packages
Name         : mysql-common
Version      : 8.0.32
Release      : 1.0.2.al8
Architecture : x86_64
Size         : 137 k
Source       : mysql-8.0.32-1.0.2.al8.src.rpm
Repository   : alinux3-updates
Summary      : The shared files required for MySQL server and client
URL          : http://www.mysql.com
License      : GPLv2 with exceptions and LGPLv2 and BSD
Description  : The mysql-common package provides the essential shared files for any
             : MySQL program. You will need to install this package to use any other
             : MySQL package.

# yum info mysql-server.x86_64
Last metadata expiration check: 0:36:05 ago on Mon 18 Mar 2024 10:01:02 AM CST.
Available Packages
Name         : mysql-server
Version      : 8.0.32
Release      : 1.0.2.al8
Architecture : x86_64
Size         : 32 M
Source       : mysql-8.0.32-1.0.2.al8.src.rpm
Repository   : alinux3-updates
Summary      : The MySQL server and related files
URL          : http://www.mysql.com
License      : GPLv2 with exceptions and LGPLv2 and BSD
Description  : MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
             : client/server implementation consisting of a server daemon (mysqld)
             : and many different client programs and libraries. This package contains
             : the MySQL server and some accompanying files and directories.

# yum info mysql.x86_64
Last metadata expiration check: 0:36:24 ago on Mon 18 Mar 2024 10:01:02 AM CST.
Available Packages
Name         : mysql
Version      : 8.0.32
Release      : 1.0.2.al8
Architecture : x86_64
Size         : 15 M
Source       : mysql-8.0.32-1.0.2.al8.src.rpm
Repository   : alinux3-updates
Summary      : MySQL client programs and shared libraries
URL          : http://www.mysql.com
License      : GPLv2 with exceptions and LGPLv2 and BSD
Description  : MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
             : client/server implementation consisting of a server daemon (mysqld)
             : and many different client programs and libraries. The base package
             : contains the standard MySQL client programs and generic MySQL files.

ben发布于博客园

执行安装

# yum install mysql-server

Last metadata expiration check: 0:40:37 ago on Mon 18 Mar 2024 10:01:02 AM CST.
Dependencies resolved.

……省略……

Installed:
  libaio-0.3.112-1.2.al8.x86_64        mariadb-connector-c-config-3.2.6-1.al8.noarch mecab-0.996-2.al8.x86_64          mysql-8.0.32-1.0.2.al8.x86_64 mysql-common-8.0.32-1.0.2.al8.x86_64
  mysql-errmsg-8.0.32-1.0.2.al8.x86_64 mysql-server-8.0.32-1.0.2.al8.x86_64          protobuf-lite-3.5.0-15.al8.x86_64

Complete!

安装完成。

 

启动服务

安装后检查服务状态:

# systemctl status mysql
Unit mysql.service could not be found.
[root@hostname nginx]# systemctl status mysqld
● mysqld.service - MySQL 8.0 database server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: enabled)
   Active: inactive (dead)

默认开机启动。

安装后,未启动。

启动服务:

# systemctl start mysqld.service

成功。

再次查看服务状态:

# systemctl status mysqld.service
● mysqld.service - MySQL 8.0 database server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2024-03-18 10:59:16 CST; 28s ago

……省略……

Mar 18 10:59:09 hostname systemd[1]: Starting MySQL 8.0 database server...
Mar 18 10:59:09 hostname mysql-prepare-db-dir[260036]: Initializing MySQL database
Mar 18 10:59:16 hostname systemd[1]: Started MySQL 8.0 database server.

已启动。

查看 mysql 进程:

# ps -ef | grep mysql
mysql     260116       1  2 10:59 ?        00:00:01 /usr/libexec/mysqld --basedir=/usr

只有一个。

ben发布于博客园

验证服务器

安装后,可以使用 mysql 的 root 用户(root@localhost) 访问,默认 不需要密码。

默认端口 3306。

# mysql -uroot 

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 8.0.32 Source distribution

Copyright (c) 2000, 2023, 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>

查看 默认数据库,有 4个。

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

用户表 user 在 mysql 数据库中。

mysql> desc mysql.user;

查看 mysql.user 表的用户基本信息:

mysql> select user,host,authentication_string,plugin from mysql.user;

注意,这里的 dev@localhost 账号是 后面自己添加的,不是系统默认的。

 

注意,可以给 没有密码的 root 用户添加密码的。

 

mysql相关命令的位置

mysql

# whereis mysql
mysql: /usr/bin/mysql /usr/lib64/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz

# ls /usr/bin | grep mysql
mysql
mysqladmin
mysqlbinlog
mysqlcheck
mysql_config_editor
mysqld_pre_systemd
mysqldump
mysqldumpslow
mysqlimport
mysql_migrate_keyring
mysqlpump
mysql_secure_installation
mysqlshow
mysqlslap
mysql_ssl_rsa_setup
mysql_tzinfo_to_sql
mysql_upgrade

ben发布于博客园

mysqld

服务器命令(ps -ef 中可见)。

# whereis mysqld
mysqld: /usr/sbin/mysqld /usr/libexec/mysqld /usr/share/man/man8/mysqld.8.gz

# ls /usr/sbin | grep mysql
mysqld

# ls /usr/libexec | grep mysql
mysql-check-socket
mysql-check-upgrade
mysqld
mysql-prepare-db-dir
mysql-scripts-common
mysql-wait-stop

 

服务器配置

配置文件位于:/etc/my.cnf.d 目录下(/etc/my.cnf 指向这里)。

# cat ../my.cnf
#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

# pwd
/etc/my.cnf.d

my.cnf.d]# ls
client.cnf  mysql-default-authentication-plugin.cnf  mysql-server.cnf

mysql-server.cnf 文件内容(默认)

 

执行 服务器配置 修改:

在 /etc/my.cnf.d/ mysql-server.cnf 添加下面的内容:

# 端口

port=33306

# 默认字符集
character_set_server=utf8mb4

说明,utf8mb4 支持 emoji 表情等,真正的 utf8。ben发布于博客园

 

修改服务器后,重启mysql:

# systemctl restart mysqld.service

成功。

ben发布于博客园

创建 mysql 用户及授权

针对 本文的 mysql version 8。

执行:创建

mysql> create user 'dev'@'%' identified by 'password';
Query OK, 0 rows affected (0.01 sec)

没有授权的 用户,登录后 只能看到 2个数据库:

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| performance_schema |
+--------------------+
2 rows in set (0.00 sec)

查看此时的权限

mysql> show grants for 'dev'@'%';
+---------------------------------+
| Grants for dev@%                |
+---------------------------------+
| GRANT USAGE ON *.* TO `dev`@`%` |
+---------------------------------+
1 row in set (0.00 sec)

 

执行:授权

mysql> grant all privileges on *.* to 'dev'@'%';
Query OK, 0 rows affected (0.01 sec)

授予了所有权限。

注意,存在风险,真实情况应该根据需要授权。权限名称 可以参考 mysql.user 表 的 以“_priv” 几位的字段名。

ben发布于博客园

新用户登录

# mysql -udev -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 8.0.32 Source distribution

Copyright (c) 2000, 2023, 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>

成功。

ben发布于博客园

本文涉及命令

  1. yum search mysql
  2. yum info mysql-common.x86_64
  3. yum install mysql-server
  4. systemctl status mysql
  5. systemctl start mysqld.service
  6. mysql -uroot 
  7. show databases;
  8. desc mysql.user;
  9. whereis mysql
  10. systemctl restart mysqld.service
  11. select user,host,authentication_string,plugin from mysql.user;
  12. create user 'dev'@'%' identified by 'password';
  13. grant all privileges on *.* to 'dev'@'%';
  14. mysql -uroot
  15. msyql -udev -p
  16.  

 

 

---END---

ben发布于博客园

本文链接:

https://www.cnblogs.com/luo630/p/18080234

ben发布于博客园

参考资料

1、

 

ben发布于博客园

ben发布于博客园

 

标签:8.0,x86,mysql,server,yum,MySQL,64,安装
From: https://www.cnblogs.com/luo630/p/18080234

相关文章

  • driver-class-name: com.mysql.jdbc.Driver爆红解决方式
    目录问题解决方式一:手动添加mysql的jar包问题问题:在springboot项目工程中想要进行数据库配置,在application.yml中添加以下代码:#数据库配置spring:datasource:driver-class-name:com.mysql.cj.jdbc.Driverusername:root#你本地的数据库用户名password......
  • k8s的安装与启动
    k8s是一个非常庞大的组件,对新手不太友好,由于版本升级和环境问题常常安装失败。这里记录一下2024年3月29日使用最新的k8s的安装和启动流程。我是在一台虚拟机中进行实验的,当前的虚拟机比较干净。先装一个docker,这个比较容易,在docker官网可以找到安装最新docker的教程。kernelmod......
  • 【GitLab】Ubuntu使用宝塔安装GitLab最新社区版
    首先在Ubuntu安装宝塔面板在官网可以找到脚本一键安装安装GitLab社区版然后在宝塔面板的“软件商店”里面找到GitLab最新社区版12.8.1一键安装安装过程中可能出现以下问题:1.卡在ruby_block[waitforlogrotateservicesocket]actionrun解决办法:在Ubuntu终端中运行......
  • Node+Vue毕设音乐制作资源分享网站(程序+mysql+Express)
    本系统(程序+源码)带文档lw万字以上 文末可获取本课题的源码和程序系统程序文件列表系统的选题背景和意义选题背景:在音乐创作和制作的领域,资源的获取与分享一直是创作者们非常关注的话题。随着互联网的普及与发展,人们越来越倾向于通过网络平台交流思想、分享作品以及寻找......
  • Node+Vue毕设音乐推荐网站(程序+mysql+Express)
    本系统(程序+源码)带文档lw万字以上 文末可获取本课题的源码和程序系统程序文件列表系统的选题背景和意义选题背景:在当今信息化时代,音乐已经成为人们生活中的重要元素之一。随着互联网技术的不断发展,人们对于音乐的消费方式也在发生着翻天覆地的变化。传统的音乐传播方式......
  • Ubuntu Server安装界面并VNC连接
    参考:公网环境下使用VNC远程连接Ubuntu系统桌面https://blog.csdn.net/qq_63320529/article/details/134506820apt更新一下sudoaptupdatesudoaptupgrade使用xfce界面安装lightdmsudoaptinstalllightdm启动lightdm服务sudosystemctlenablelightdm......
  • Python数据库编程全指南SQLite和MySQL实践
    1.安装必要的库首先,我们需要安装Python的数据库驱动程序,以便与SQLite和MySQL进行交互。对于SQLite,Python自带了支持;而对于MySQL,我们需要安装额外的库,如mysql-connector-python。#安装MySQL连接器pipinstallmysql-connector-python2.连接SQLite数据库SQLite是一......
  • linux离线安装jenkins及使用教程
    本教程采用jenkins.war的方式离线安装部署,在线下载的方式会遇到诸多问题,不宜采用一、下载地址地址:Jenkinsdownloadanddeployment下载最新的长期支持版由于jenkins使用java开发的,所以需要安装的linux服务器装有jdk环境,并且jdk版本支持你所安装的jenkins版本点击 Hard......
  • MySQL - [06] 海贼王测试数据
     一、建表语句createtablerole(roleIdintnullcomment'角色id',namevarchar(32)nullcomment'姓名',apearNumvarchar(50)nullcomment'登场集数',addressvarchar(50)nullcomment'上传地点',......
  • CentOs云服务器安装docker+前端部署(仅http)
    安装dockersudoyum-config-manager--add-repohttps://download.docker.com/linux/centos/docker-ce.reposudoyuminstalldocker-cedocker-ce-clicontainerd.io设置开机自启:systemctlenabledocker.service创建docker网络,网络名字自定义dockernetworkcreatebalab......