mysql的下载安装
想要使用MySQL来存储并保存数据,则需要做几件事情:
a. 安装MySQL服务端
b. 安装MySQL客户端
b. 【客户端】连接【服务端】
c. 【客户端】发送命令给【服务端MySQL】服务的接受命令并执行相应操作(增删改查等)
下载地址:
https://dev.mysql.com/downloads/mysql/
window版本
1、官网去下载,下偶不下基
2、针对操作系统的不同下载不同的版本
3.解压
如果想要让MySQL安装在指定目录,那么就将解压后的文件夹移动到指定目录,如:C:\mysql-5.6.40-winx64
4.添加环境变量
5. 需要配置下 MySQL 的配置文件
打开刚刚解压的文件夹,在该文件夹下创建 config.ini 配置文件,编辑 config.ini 配置以下基本信息:
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [mysqld] # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # These are commonly set, remove the # and set as required. basedir = D:\download\mysql-5.6.44-winx64; datadir = D:\download\mysql-5.6.44-winx64\data # port = ..... # server_id = ..... # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES # mysql端口 port=3306 # 字符集 [mysqld] character-set-server=utf8 collation-server=utf8_general_ci [client] default-character-set=utf8 [mysql] default-character-set=utf8
5.初始化
1
|
mysqld - - initialize - insecure |
6.初始化
以管理员身份打开 cmd 命令行工具,切换目录:
cd C:\mysql-5.6.40-winx64\bin
初始化数据库:
mysqld --initialize --console
输入以下安装命令:
mysqld install
在mysql-5.6.40-winx64目录下就会生成data目录
启动输入以下命令即可:
net start mysql
注意: 在 5.7 需要初始化 data 目录:
mysqld --initialize-insecure
初始化后再运行 net start mysql 即可启动 mysql。
7. 启动mysql客户端并连接mysql服务端(新开一个cmd窗口)
mysql -u root -p # 连接MySQL服务器
参数说明:
- -h : 指定客户端所要登录的 MySQL 主机名, 登录本机(localhost 或 127.0.0.1)该参数可以省略;
- -u : 登录的用户名;
- -p : 告诉服务器将会使用一个密码来登录, 如果所要登录的用户名密码为空, 可以忽略此选项。
如果我们要登录本机的 MySQL 数据库,只需要输入以下命令即可:
mysql -u root -p
按回车确认, 如果安装正确且 MySQL 正在运行, 会得到以下响应:
Enter password:
若密码存在, 输入密码登录, 不存在则直接按回车登录。登录成功后你将会看到 Welcome to the MySQL monitor... 的提示语。
然后命令提示符会一直以 mysq> 加一个闪烁的光标等待命令的输入, 输入 exit 或 quit 退出登录。
来源:https://www.cnblogs.com/Summer-skr--blog/p/11753420.html