#先查询mysql
webrx@us:~$ sudo apt search mysql-server
正在排序... 完成
全文搜索... 完成
default-mysql-server/focal 1.0.5ubuntu2 all
MySQL database server binaries and system database setup (metapackage)
default-mysql-server-core/focal 1.0.5ubuntu2 all
MySQL database server binaries (metapackage)
mysql-server/focal-updates,focal-security 8.0.27-0ubuntu0.20.04.1 all
MySQL database server (metapackage depending on the latest version)
mysql-server-8.0/focal-updates,focal-security 8.0.27-0ubuntu0.20.04.1 amd64
MySQL database server binaries and system database setup
mysql-server-core-8.0/focal-updates,focal-security 8.0.27-0ubuntu0.20.04.1 amd64
MySQL database server binaries
#安装mysql
sudo apt install mysql-server -y
#查看mysql服务
webrx@us:~$ sudo systemctl status mysql
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; ven>
Active: active (running) since Mon 2021-12-20 10:52:57 CST; 2mi>
Main PID: 5142 (mysqld)
Status: "Server is operational"
Tasks: 37 (limit: 4583)
Memory: 355.5M
CGroup: /system.slice/mysql.service
└─5142 /usr/sbin/mysqld
12月 20 10:52:56 us systemd[1]: Starting MySQL Community Server...
12月 20 10:52:57 us systemd[1]: Started MySQL Community Server.
lines 1-12/12 (END)
#查看进程号
webrx@us:~$ ps -ef | grep mysql
mysql 5142 1 0 10:52 ? 00:00:01 /usr/sbin/mysqld
webrx 5761 1214 0 10:55 pts/0 00:00:00 grep --color=auto mysql
#登录mysql
webrx@us:~$ sudo mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.27-0ubuntu0.20.04.1 (Ubuntu)
Copyright (c) 2000, 2021, 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.
mysql> select version();
+-------------------------+
| version() |
+-------------------------+
| 8.0.27-0ubuntu0.20.04.1 |
+-------------------------+
1 row in set (0.00 sec)
mysql> show databases;
+--------------------+
| Database
mysql安装#先查询mysqlwebrx@us:~$ sudo apt search mysql-server正在排序... 完成全文搜索... 完成 default-mysql-server/focal 1.0.5ubuntu2 all MySQL database server binaries and system database setup (metapackage)default-mysql-server-core/focal 1.0.5ubuntu2 all M