数据库的安装(mysql)
概述:
MySQL是一个中小型关系数据库管理系统,开发者为瑞典MySQL AB公司。在2008年1月16号被sun公司10亿美金收购。2009年,SUN又被Oracle以74亿美金收购。
目前MySQL被广泛地应用在Internet上的中小型网站中。由于体积小、速度快、总体拥有成本低,尤其是开放源代码这一特点,许多中小型网站为了降低网站总体拥有成本而选择了MySQL作为网站数据库。
-
使用C和C++编写,并使用了多种编译器进行测试,保证源代码的可移植性。
-
支持AIX、BSDi、FreeBSD、HP-UX、Linux、Mac OS、Novell Netware、NetBSD、OpenBSD、OS/2 Wrap、Solaris、SunOS、Windows等多种操作系统。
-
为多种编程语言提供了API。这些编程语言包括C、C++、C#、Delphi、Eiffel、Java、Perl、PHP、Python、Ruby和Tcl等。
-
支持多线程,充分利用CPU资源,支持多用户。
1.下载mysql
官网:www.mysql.com
或者在:MySQL :: 下载 MySQL Community Server (存档版本)
选择版本和操作系统,这里我们选择windows操作系统和8.4.3版本
2.mysql的安装方式
具有两种安装方式
以Windows的安装程序安装(msi)和压缩包解压的安装方式(zip)
前者的安装更“傻瓜式”
后者的安装更“透明”
3.mysql(msi的安装方式)
这三种安装方式对应典型,客户,完全
一般来说我们作为学习者选择典型的方式
后面切换我们的安装路径即可
设置密码等不必过多赘述
默认端口为3306
4.mysql(压缩包的安装方式)
下载好压缩包后解压到我们需要放置的文件夹
解压完成后设置一个配置文件
在主目录下复制、创建一个xx.ini,修改为my.ini
,修改其中的basedir
和datadir
basedir=mysql主目录 datadir=mysql主目录/data
配置如图举例
还要配置路径
在高级系统设置中选择
选择全局或者个人的路径
地址为自己解压的路径
以管理员身份打开该文件夹的cmd
mysqld --initialize --console
初始化mysql
-
然后mysql服务创建
mysqld --install
-
启动服务:
net start mysql
-
登陆旧密码登陆:
mysql -u root -p
5.进入mysql
简单的命令
查看安装的MySQL版本:
mysql -V
使用帮助命令
mysql> \hFor information about MySQL products and services, visit:http://www.mysql.com/
For developer information, including the MySQL Reference Manual, visit:http://dev.mysql.com/
To buy MySQL Enterprise support, training, or other products, visit:https://shop.mysql.com/List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
? (\?) Synonym for `help'.
clear (\c) Clear the current input statement.
connect (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter.
ego (\G) Send command to mysql server, display result vertically.
exit (\q) Exit mysql. Same as quit.
go (\g) Send command to mysql server.
help (\h) Display this help.
notee (\t) Don't write into outfile.
print (\p) Print current command.
prompt (\R) Change your mysql prompt.
quit (\q) Quit mysql.
rehash (\#) Rebuild completion hash.
source (\.) Execute an SQL script file. Takes a file name as an argument.
status (\s) Get status information from the server.
system (\!) Execute a system shell command.
tee (\T) Set outfile [to_outfile]. Append everything into given outfile.
use (\u) Use another database. Takes database name as argument.
charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
warnings (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.
resetconnection(\x) Clean session context.For server side help, type 'help contents'
查看MySQL终端命令:help
如何查询当前数据库管理下存在多少数据库:
show databases;
进入某个数据库
use 数据库名称
查询当前数据库下的表:
show tables;