2021-08-25

本文档详细介绍了MySQL的下载、安装和配置过程,包括创建my.ini配置文件、设置环境变量、初始化数据库、安装服务、修改用户密码以及解决客户端连接问题。在遇到权限错误和已存在服务的情况下,提供了相应的解决策略。
摘要由CSDN通过智能技术生成

MYSQL安装
从官网选择对应的版本下载64位的zip包:
https://dev.mysql.com/downloads/mysql/
在这里插入图片描述

备注:正常来说下载第一个,第二个是调试版本,下载之后解压到文件夹,不要有中文目录
在这里插入图片描述

解压后新建一个my.ini,内容如下,需要修改basedir和datadir

# For advice on how to change settings please see
# http=//dev.mysql.com/doc/refman/5.7/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.

[client]
 port = 3306
 default-character-set = utf8

[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
port = 3306 
# These are commonly set, remove the # and set as required.
basedir="D:\...\mysql"
datadir="D:\...\mysql/data/"
# server_id = .....
character_set_server = utf8
 
# 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_HOME
值:F:\Workspace\mysql-8.0.24-winx64
在path中增加:%MYSQL_HOME\bin
切换到bin目录下初始化数据库:mysqld --initialize-insecure --user=mysql
安装数据库:mysqld –install
报错:Install/Remove of the Service Denied!
解决办法:以管理员身份运行
报错:The service already exists! 说明之前安装过,把之前的删掉重新安装
查询是否安装过:sc query mysql
删除安装的mysql: sc delete mysql
显示:Service successfully installed. 证明已经安装成功
启动服务:net start mysql
关闭服务:net stop mysql
卸载服务:mysql --remove
登录数据库:mysql –u root -p 回车直接登录
显示数据库:show databases;
输入:user mysql;
修改密码语句:ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘admin123’;
更新权限:flush privileges;
退出:quit;
客户端连接mysql报错:1251 client does not support
在这里插入图片描述
解决:
查看用户信息:select host,user,plugin,authentication_string from mysql.user;
在这里插入图片描述
修改密码
修改用户密码
ALTER USER ‘root’@’%’ IDENTIFIED WITH mysql_native_password BY ‘admin123’;
备注:这个需要给root用户开启远程权限,不然执行会报错:ERROR 1396 (HY000): Operation ALTER USER failed for ‘root’@’%’,因为‘%’是指所有远程终端都可以连接登录
ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘admin123’;
修改后连接成功
在这里插入图片描述

以下是将XML转换为.NET Core实体模型的代码示例: ```csharp using System.Xml.Serialization; [XmlRoot(ElementName = "OTA_InventoryCheckRS")] public class InventoryCheckResponse { [XmlAttribute(AttributeName = "TimeStamp")] public string TimeStamp { get; set; } [XmlAttribute(AttributeName = "Version")] public string Version { get; set; } [XmlAttribute(AttributeName = "EchoToken")] public string EchoToken { get; set; } [XmlElement(ElementName = "HotelResult")] public HotelResult HotelResult { get; set; } } public class HotelResult { [XmlElement(ElementName = "HotelID")] public string HotelID { get; set; } [XmlElement(ElementName = "HotelProducts")] public HotelProducts HotelProducts { get; set; } } public class HotelProducts { [XmlElement(ElementName = "HotelProduct")] public HotelProduct HotelProduct { get; set; } } public class HotelProduct { [XmlElement(ElementName = "FreeCancelable")] public FreeCancelable FreeCancelable { get; set; } [XmlElement(ElementName = "RoomTypes")] public RoomTypes RoomTypes { get; set; } [XmlElement(ElementName = "RatePlans")] public RatePlans RatePlans { get; set; } [XmlElement(ElementName = "Prices")] public Prices Prices { get; set; } } public class FreeCancelable { [XmlAttribute(AttributeName = "FreeCancelableVal")] public string FreeCancelableVal { get; set; } } public class RoomTypes { [XmlElement(ElementName = "RoomType")] public RoomType RoomType { get; set; } } public class RoomType { [XmlAttribute(AttributeName = "RoomTypeCode")] public string RoomTypeCode { get; set; } } public class RatePlans { [XmlElement(ElementName = "RatePlan")] public RatePlan RatePlan { get; set; } } public class RatePlan { [XmlAttribute(AttributeName = "RatePlanCode")] public string RatePlanCode { get; set; } } public class Prices { [XmlElement(ElementName = "Price")] public Price Price { get; set; } } public class Price { [XmlElement(ElementName = "Base")] public Base Base { get; set; } } public class Base { [XmlAttribute(AttributeName = "EffectDate")] public string EffectDate { get; set; } [XmlAttribute(AttributeName = "SalePrice")] public string SalePrice { get; set; } [XmlAttribute(AttributeName = "BasePrice")] public string BasePrice { get; set; } [XmlAttribute(AttributeName = "Allotment")] public string Allotment { get; set; } [XmlAttribute(AttributeName = "DcOverSaleAllotment")] public string DcOverSaleAllotment { get; set; } [XmlAttribute(AttributeName = "DcAddAllotment")] public string DcAddAllotment { get; set; } [XmlAttribute(AttributeName = "DcContractAllotment")] public string DcContractAllotment { get; set; } [XmlAttribute(AttributeName = "DcBuyOutAllotment")] public string DcBuyOutAllotment { get; set; } } ``` 在调用方代码中,您可以使用以下代码将XML转换为.NET Core实体模型: ```csharp string xml = "<OTA_InventoryCheckRS TimeStamp=\"1629879848173\" Version=\"1.000\" EchoToken=\"18029461-194a-4c7e-b372-6eec346cebd4\"> <HotelResult> <HotelID>10000007</HotelID> <HotelProducts> <HotelProduct> <!--只有支持30分钟免费取消的酒店,才需要返回该节点--> <FreeCancelable FreeCancelableVal=\"true\" /> <RoomTypes> <RoomType RoomTypeCode=\"2106\"/> </RoomTypes> <RatePlans> <RatePlan RatePlanCode=\"302-4529\"/> </RatePlans> <Prices> <Price> <Base EffectDate=\"2021-08-25\" SalePrice=\"515.2\" BasePrice=\"515.2\" Allotment=\"53\" DcOverSaleAllotment=\"53\" DcAddAllotment=\"-1\" DcContractAllotment=\"-1\" DcBuyOutAllotment=\"-1\"/> </Price> </Prices> </HotelProduct> </HotelProducts> </HotelResult> </OTA_InventoryCheckRS>"; XmlSerializer serializer = new XmlSerializer(typeof(InventoryCheckResponse)); using StringReader reader = new StringReader(xml); InventoryCheckResponse response = (InventoryCheckResponse)serializer.Deserialize(reader); ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值