MySQL安装以及客户端的使用
安装:
[root@yang ~]# wget -O /usr/src/mysql57-community-release-el7-10.noarch.rpm \
> http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
--2021-08-23 22:43:24-- http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
正在解析主机 dev.mysql.com (dev.mysql.com)... 137.254.60.11
正在连接 dev.mysql.com (dev.mysql.com)|137.254.60.11|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 301 Moved Permanently
位置:https://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm [跟随至新的 URL]
--2021-08-23 22:43:24-- https://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
正在连接 dev.mysql.com (dev.mysql.com)|137.254.60.11|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 302 Found
位置:https://repo.mysql.com//mysql57-community-release-el7-10.noarch.rpm [跟随至新的 URL]
--2021-08-23 22:43:26-- https://repo.mysql.com//mysql57-community-release-el7-10.noarch.rpm
正在解析主机 repo.mysql.com (repo.mysql.com)... 23.44.151.164
正在连接 repo.mysql.com (repo.mysql.com)|23.44.151.164|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:25548 (25K) [application/x-redhat-package-manager]
正在保存至: “/usr/src/mysql57-community-release-el7-10.noarch.rpm”
/usr/src/mysql57-c 100%[=============>] 24.95K --.-KB/s 用时 0.06s
2021-08-23 22:43:26 (412 KB/s) - 已保存 “/usr/src/mysql57-community-release-el7-10.noarch.rpm” [25548/25548])
[root@yang ~]#
下载mariadb 和 mariadb-server
[root@yang ~]# yum -y install mariadb mariadb-server
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
CentOS-8 - Base - mirrors.aliyun.com 11 kB/s | 3.9 kB 00:00
CentOS-8 - Base - mirrors.aliyun.com 4.2 MB/s | 5.6 MB 00:01
CentOS-8 - Extras - mirrors.aliyun.com 4.6 kB/s | 1.5 kB 00:00
CentOS-8 - Extras - mirrors.aliyun.com 15 kB/s | 10 kB 00:00
CentOS-8 - AppStream - mirrors.aliyun.co 13 kB/s | 4.3 kB 00:00
CentOS-8 - AppStream - mirrors.aliyun.co 3.3 MB/s | 8.8 MB 00:02
上次元数据过期检查:0:00:01 前,执行于 2021年08月23日 星期一 22时44分46秒。
依赖关系解决。
.....
设置开机自启
[root@yang ~]# systemctl enable --now mariadb
Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.
[root@yang ~]#
设置密码
[root@yang ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.3.28-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> set password = password("yang123");
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]> exit
Bye
[root@yang ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@yang ~]# mysql -uroot -pyang123
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 10.3.28-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
简单使用
//查看版本
[root@yang ~]# mysql -V
mysql Ver 15.1 Distrib 10.3.28-MariaDB, for Linux (x86_64) using readline 5.1
//在外查看数据库
[root@yang ~]# mysql -uroot -pyang123 -e 'show databases;'
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
[root@yang ~]#