MySQL:是一种数据库管理系统,管理关系型数据库,相当于存放了很多 excel 表格。
数据库管理系统:用来管理数据库的计算机系统称为数据库管理系统(DataBase Management System,DBMS)。
sudo apt update
sudo apt install mysql-server
进入mysql命令行设置root用户的密码
sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '0978X&js';
exit
在shell中设置其他安全信息 全部回答Y
sudo mysql_secure_installation
# 创建一个用户 admin
CREATE USER 'admin'@'localhost' IDENTIFIED BY '1568X&js';
# 查看用户权限
SHOW GRANTS FOR admin@localhost;
# 给予所有权限
GRANT ALL ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;
以admin身份登录MySQL
mysql -u admin -p
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.33-0ubuntu0.22.04.2 (Ubuntu)
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>
删除用户
DROP USER admin@localhost;
# 创建数据库s50
create database s50
# 查看所有数据库列表
show databases;
# 使用数据库s50
use s50
# 显示现在正在使用的数据库名字
SELECT DATABASE();
# 现在的数据库中有哪些 table
SHOW TABLES;
# 删除数据库s50
drop database s50
联系客服