进入mysql数据库
1
#mysql -uroot -proot
创建mysql user
1
2MariaDB [(none)]> create user 'stock'@'localhost' identified by 'stock';
Query OK, 0 rows affected (0.00 sec)查询mysql用户
1
2
3
4
5
6
7
8MariaDB [(none)]> SELECT User,Host FROM mysql.user;
+-------+-----------+
| User | Host |
+-------+-----------+
| root | localhost |
| stock | localhost |
+-------+-----------+
2 rows in set (0.00 sec)授予mysql用户权限
1
2MariaDB [(none)]> GRANT ALL ON stock.* TO 'stock'@'localhost';
Query OK, 0 rows affected (0.00 sec)使用show语句查找数据库
1
2
3
4
5
6
7
8
9MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)创建数据库stock
1
2MariaDB [(none)]> create database stock;
Query OK, 1 row affected (0.00 sec)选择创建的数据库
1
2MariaDB [(none)]> use stock;
Database changed使用show语句查找数据库中的表
1
MariaDB [stock]> show tables;
删除创建的数据库
1
2MariaDB [(none)]> drop database stock;
Query OK, 0 rows affected (0.00 sec)删除表
1
2mysql> drop table sequelizemeta;
Query OK, 0 rows affected (0.01 sec)查询表结构
1
mysql> desc t_records;
清除表记录
1
mysql> delete from t_records;
修改数据库账号密码
1 | mysqladmin -uroot -p123456 password 123 |
参考链接
- 什么是 MySQL 索引?,by 小灰.
- mysql修改用户密码的方法及命令,by 剩余价值.