MYSQL的安装及基本操作
程序员文章站
2024-01-22 23:18:10
...
百度软件中心下载mysql,安装后出现一下页面:
其中MySQL Server 5.7属于后台,打开cmd,进入MySQL Server 5.7的bin页面
查看mysql版本:
C:\Program Files\MySQL\MySQL Server 5.7\bin>mysqladmin --version
mysqladmin Ver 8.42 Distrib 5.7.20, for Win64 on x86_64
运行关闭mysql服务器:
查看资源管理器mysqld(服务器)是否运行,若没有运行,输入mysqld启动它:
C:\Program Files\MySQL\MySQL Server 5.7\bin>mysqld
mysqld: Can't change dir to 'C:\Program Files\MySQL\MySQL Server 5.7\data\' (Errcode: 2 - No such file or directory)
2018-04-25T10:35:17.529655Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-04-25T10:35:17.529655Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2018-04-25T10:35:17.529655Z 0 [Note] mysqld (mysqld 5.7.20) starting as process 2428 ...
关闭服务器:
C:\Program Files\MySQL\MySQL Server 5.7\bin>mysqladmin -u root -p shutdown
Enter password: ******
设置密码:
MySQL附带了一个空密码有的root用户。成功后安装了数据库和客户端,需要进行如下设置root密码:
C:\Program Files\MySQL\MySQL Server 5.7\bin> mysqladmin -u root password "123456";
登陆数据库C:\Users\Administrator>cd C:\Program Files\MySQL\MySQL Server 5.7\bin
C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -u root -p
Enter password:
创建数据库tutorials:
C:\Program Files\MySQL\MySQL Server 5.7\bin>mysqladmin -u root -p create tutorials
Enter password: ******
(或使用)
D:\software\mysql-5.6.25-winx64\bin> mysql -u root -p
Enter password:
mysql>create database yiibai_tutorials1;
mysql>create database yiibai_tutorials2;
显示数据库:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
| yiibai_tutorials1 |
| yiibai_tutorials2 |
+--------------------+
6 rows in set (0.00 sec)
删除数据库:
D:\software\mysql-5.6.25-winx64\bin> mysqladmin -u root -p drop yiibai_tutorials1
Enter password:******
(或使用)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
| yiibai_tutorials1 |
| yiibai_tutorials2 |
+--------------------+
6 rows in set (0.00 sec)
选择数据库:
D:\software\mysql-5.6.25-winx64\bin> mysql -u root -p
Enter password:
mysql> use test;
Database changed
mysql>
创建表:
mysql> CREATE TABLE tutorials_tbl(
-> tutorial_id INT NOT NULL AUTO_INCREMENT,
-> tutorial_title VARCHAR(100) NOT NULL,
-> tutorial_author VARCHAR(40) NOT NULL,
-> submission_date DATE,
-> PRIMARY KEY ( tutorial_id )
-> );
Query OK, 0 rows affected (0.16 sec)
注: MySQL不会终止命令,直到给一个分号(;)表示SQL命令结束。
插入数据:
INSERT INTO tutorials_tbl
(tutorial_title, tutorial_author, tutorial_id,submission_date)
VALUES
("学习", "sft", "151304104",Now());
删除表:
DROP TABLE table_name ;
注意:mysql>对数据库操作内容==脚本中对数据库操作的内容上一篇: MongoDB_文档_查询
下一篇: “快手短视频”怎么引流卖货赚钱?