Django笔记-MySQL初次使用设置

以下为个人学习时的笔记,正在完善中。。。。。。。。。。。

【1】启动服务

[root@bogon /]# service mysqld start
正在启动 mysqld: [确定]

[root@bogon /]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

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.


【2】查看默认设置
mysql> select user,host,password from mysql.user;
+------+-----------+----------+
| user | host | password |
+------+-----------+----------+
| root | localhost | |
| root | bogon | |
| root | 127.0.0.1 | |
| | localhost | |
| | bogon | |
+------+-----------+----------+
5 rows in set (0.00 sec)

mysql>

【3】设置root用户密码
mysql> update mysql.user set password=PASSWORD('djg123')where User='root';
Query OK, 3 rows affected (0.01 sec)
Rows matched: 3 Changed: 3 Warnings: 0

mysql>

【4】更改成功
mysql> select user,host,password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| root | localhost | *2BE7655D6B576E2BBC1D1ECF9261F72CD0FCB539 |
| root | bogon | *2BE7655D6B576E2BBC1D1ECF9261F72CD0FCB539 |
| root | 127.0.0.1 | *2BE7655D6B576E2BBC1D1ECF9261F72CD0FCB539 |
| | localhost | |
| | bogon | |
+------+-----------+-------------------------------------------+
5 rows in set (0.00 sec)

mysql>

【5】查看有哪些数据库
mysql> show database;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'database' at line 1
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.02 sec)

【6】使用test数据库,作为测试样例
mysql> use test;
Database changed


mysql> show tables;
Empty set (0.01 sec)

【创建表格,并插入数据】
mysql> create table user (name varchar(20),password char(20),id int(5));
Query OK, 0 rows affected (0.03 sec)

mysql> insert into user values('Tom','tomok',5);
Query OK, 1 row affected (0.00 sec)


mysql> select * from user;
+------+----------+------+
| name | password | id |
+------+----------+------+
| Tom | tomok | 5 |
+------+----------+------+
1 row in set (0.00 sec)


mysql> quit
Bye

 

posted @   VNX  阅读(408)  评论(0编辑  收藏  举报
编辑推荐:
· .NET 原生驾驭 AI 新基建实战系列:向量数据库的应用与畅想
· 从问题排查到源码分析:ActiveMQ消费端频繁日志刷屏的秘密
· 一次Java后端服务间歇性响应慢的问题排查记录
· dotnet 源代码生成器分析器入门
· ASP.NET Core 模型验证消息的本地化新姿势
阅读排行:
· ThreeJs-16智慧城市项目(重磅以及未来发展ai)
· .NET 原生驾驭 AI 新基建实战系列(一):向量数据库的应用与畅想
· Ai满嘴顺口溜,想考研?浪费我几个小时
· Browser-use 详细介绍&使用文档
· 软件产品开发中常见的10个问题及处理方法
点击右上角即可分享
微信分享提示