• echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // This SQL statement selects ALL from the table 'Equipment' $sql = "SELECT name FROM TABLE WHERE name = ‘$CHANGE THIS’ "; // ...
  • 上节我们介绍了阿里云ECS上部署个Swift Perfect的实例环境的方法,下面我将继续介绍如何实际开发一个简单的服务器接口并与mysql数据库进行交互;三、依托阿里云服务器,搭建一个Perfect+mysql的服务1.运用swift包...

    上节我们介绍了阿里云ECS上部署个Swift Perfect的实例环境的方法,下面我将继续介绍如何实际开发一个简单的服务器接口并与mysql数据库进行交互;

    三、依托阿里云服务器,搭建一个Perfect+mysql的服务

    1.运用swift包管理工具建立一个干净的Perfect工程

    首先我们建立一个文件夹这里我们可以直接用FileZilla创建个文件夹,或者用命令mkdir创建个文件夹比如我建的文件夹叫WebService ;执行mkdir WebService 我们得到个空文件夹WebService;

     cd WebService

    SPM软件包管理器初始化项目:

    swift package init --type=executable


    这个命令会在当前工作目录自动生成下列文件:


    Creating executable package: WebService

    Creating Package.swift

    Creating README.html

    Creating .gitignore

    Creating Sources/

    Creating Sources/WebService/main.swift

    Creating Tests/


    若需要使用git来管理工程,则我们可以对.gitignore进行编辑来忽略一些不必要同步的文件,下面是一个通用的忽略文件


    # Created by https://www.gitignore.io/api/swift


    ### Swift ###

    # Xcode

    #

    # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore


    ## Build generated

    build/

    DerivedData/


    ## Various settings

    *.pbxuser

    !default.pbxuser

    *.mode1v3

    !default.mode1v3

    *.mode2v3

    !default.mode2v3

    *.perspectivev3

    !default.perspectivev3

    xcuserdata/


    ## Other

    *.moved-aside

    *.xccheckout

    *.xcscmblueprint


    ## Obj-C/Swift specific

    *.hmap

    *.ipa

    *.dSYM.zip

    *.dSYM


    ## Playgrounds

    timeline.xctimeline

    playground.xcworkspace


    # Swift Package Manager

    #

    # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.

    # Packages/

    # Package.pins

    .build/


    # CocoaPods - Refactored to standalone file


    # Carthage - Refactored to standalone file


    # fastlane

    #

    # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the

    # screenshots whenever they are needed.

    # For more information about the recommended setup visit:

    # https://docs.fastlane.tools/best-practices/source-control/#source-control


    fastlane/report.xml

    fastlane/Preview.html

    fastlane/screenshots

    fastlane/test_output


    #xcode文件

    *.xcodeproj


    # End of https://www.gitignore.io/api/swift


    将上面内容复制到.gitignore文件后即可通过git来同步服务端与本地的代码,由于服务端的代码修改比较麻烦,没有本地的Xcode简单,所以建议使用Git来管理代码,当这个空白的基础工程建好后,我们就可以通过服务端的git 来上传这个空白项目;为啥要上传空白项目?因为我们后面的编程将在Mac本地使用Xcode来完成;我们使用 

    git add *  


    git commit -m 描述提交的内容 

    git push --set-upstream  origin  master

    命令来上传项目内容;

    若第一次配置git可能无法提交,所以第一次我们需要配置git

    git init 命令初始化git配置

    git remote add origin {git地址}命令来添加git地址


    git上传完成后,随后我们就可以在本地Mac上同步git clone  {git地址}下载这个工程;



    工程下载完毕,我们在本地的终端上cd到工程目录,然后执行

    swift package generate-xcodeproj

    命令,这样我们就会得到一个WebService.xcodeproj工程文件,Xcode打开这个工程文件,我们就可以看到我们这个Swift空白项目了;

    首先我们要修改Package.swift文件,这个是Perfect框架的引用包;



    import PackageDescription

    let package = Package(

    name: "WebService",

    targets: [],

    dependencies: [

    .Package(url: "https://github.com/PerfectlySoft/Perfect-HTTPServer.git", majorVersion: 3),

                    .Package(url: "https://github.com/PerfectlySoft/Perfect-MySQL.git", majorVersion: 3),

    .Package(url: "https://github.com/PerfectlySoft/Perfect-RequestLogger.git", majorVersion: 3),

    .Package(url: "https://github.com/SwiftORM/MySQL-StORM.git", majorVersion: 3),

    .Package(url: "https://github.com/PerfectlySoft/Perfect-Session-MySQL.git", majorVersion: 3),

    ]

    )

    修改完成后在终端上运行swift build

    这一过程是漫长而枯燥的,耐心等待,如果出现问题请重试
    第一类错误:

    这个错误就说明,你的Package文件里配置有问题,请按照我上面说的配置,或者去点开上面的git连接,去Perfect项目官方地址上去找配置设置路径,当然当你的代码里出现编译错误时也是可能会出现这个问题的,当Xcode编译不通过时,请先解决Xcode里的编辑错误,先保证Xcode可以编译通过在来swift build我们现在还没有写逻辑代码,所以基本不会出现这个问题。

    第二类错误

    找到链接里对应的文件,删了,重新build


    swift 的项目编译文件都在WebService项目文件夹的.build文件夹里,这个文件夹是个隐藏文件夹,我们可以打开WebService文件夹按下command+shift+.组合按键来显示这个文件夹,当出现编译不通过出现某些框架无法下载时也可以删除这个文件夹来重新swift build

    2.安装mysql


    当然由于我们使用了mysql,所以在最后一步编译出错很正常,我们要在Mac中安装mysql,安装mysql的方法不在赘述,详细可参考https://www.jianshu.com/p/fd3aae701db9

    安装完mysql

    1,检查是否安装了mysql
    commond+shift+G
    输入/usr/local回车看看有没有把

    如果和笔者的一样,那你已经安装了,如果没有,那请去官网下载连接是直接到下载页面的https://dev.mysql.com/downloads/mysql/下载安装2,使用navcat或者mysqlworkbench等其它工具连接数据库,笔者用的mysqlworkbench点击左上角mysqlworkbench->Database->connect to Database来连接数据库起个名字作为WebService ,port默认,userName和password输入mysql创建时设置的密码,若改了密码就输入改后的,重要的一点事Encoding;



    编码格式是UTF-8下面有一个选项是默认勾选的,它有什么作用呢?如果你勾选上了,你会发现你存的汉字都是乱码,所以这里不勾选它。3,连接时提示你root密码错误这里笔者也是遇到了,mac下安装时,没有提示设置密码,笔者当时安装时好像是这样的,这时你要重置密码http://jingyan.baidu.com/article/63f236280a11680208ab3d91.html连接放上面了,具体我不赘述了

    再次执行swift package generate-xcodeproj

    这个时候可以用Xcode打开运行了

    运行错误解决方案 

    解决方案参考文章http://www.jianshu.com/p/c117294e2442

    错误一 

    Header '/usr/local/include/mysql/mysql.h' 

    这个错误是因为我们存放mysql.h文件的路径和它引用的路径不同。用 Homebrew安装的MySQL路径确实是正确的。 

    解决方法: 

    点击Finder,选择前往文件夹,进入/usr/local目录下,你会发现有mysql文件夹,在文件夹里找到对应mysql.h得到目录,将报错的module.modulemap文件中的路径修改成你自己的路径就可以了。这里我自己最后的路径是/usr/local/mysql-5.7.15-osx10.11-x86_64/include/mysql.h 

    错误二 

    ld: library not found for -lmysqlclient for architecture x86_64 

    解决方法: 

    在Target中找到MySQL,找到Library Search Paths中加上mysql文件夹下的lib的文件夹路径。我的是/usr/local/Cellar/mysql/5.7.16/lib

    在Target中找到PerfectTemplate找到Other Linker Flags 加上-L/usr/local/Cellar/mysql/5.7.16/lib其中在lib目录下能找到对应的mysqlclient文件。 

    当所有错误都解决的时候,你可以运行了,当然这个时候逻辑是空的,所以不会有什么效果,下面我们要为Perfect编写代码逻辑,我们在Source/WebService文件夹下建立个Service文件夹用来放我们的业务逻辑代码,并建立一个NetworkServer.swift文件


    添加如下代码

    import PerfectHTTP

    import PerfectHTTPServer

    import PerfectRequestLogger


    open class NetworkServer {

        

        let server = HTTPServer();

        let httplogger = RequestLogger();

        let requestFilter = RequestFilter();

        let responseFilter = ResponseFilter();

        

        var routes : Routes = Routes.init(baseUri: "/v1");

        

        init(serverName:String,serverPort:UInt16) {

            server.serverPort = serverPort;

            server.serverName=serverName;

            self.initRoutes();

            server.addRoutes(routes);

            server.documentRoot="./webroot";

            server.setRequestFilters([(httplogger, .high),(RequestFilter(), .low)]);

            server.setResponseFilters([(ResponseFilter(), .high),(httplogger, .low)]); 

        }

        

        func start() -> Void {

            do {

                try server.start();

            } catch {

                fatalError("\(error)"); // fatal error launching one of the servers

            }

        }

        

        func initRoutes() -> Void {

            routes.add(Route.init(methods: [.get,.post], uri: "/**", handler: handler));

        }

        

        func handler(request: HTTPRequest, response: HTTPResponse) {

          response.appendBody(string:” hellow world" );

          response.completed();

        }

        

        struct RequestFilter : HTTPRequestFilter {

            func filter(request: HTTPRequest, response: HTTPResponse, callback: (HTTPRequestFilterResult) -> ()) {

                request.setHeader(.contentType, value: "text/html;charset=UTF-8");

                callback(.continue(request, response))

            }

        }

        

        struct ResponseFilter : HTTPResponseFilter {

            func filterHeaders(response: HTTPResponse, callback: (HTTPResponseFilterResult) -> ()) {

                response.setHeader(.contentType, value: "text/html;charset=UTF-8");

                callback(.continue);

            }

            func filterBody(response: HTTPResponse, callback: (HTTPResponseFilterResult) -> ()) {

                callback(.continue);

            }

        }

    }

    在main.swift中我们加上这样一句

    let server = NetworkServer.init(serverName: "localhost", serverPort: 8181);

    server.start();

    这样我们的本地服务器就可以启动了



    当log 窗口出现如图显示log时表明服务器已经启动,有可能会出现不能识别NetworkServer类的情况这时候我们需要在Xcode里添加这个文件的引用;


    现在我们已经建立了个Perfect的工程并成功启动了服务,

    现在我们将建立个实例来使用MySQLStORM来进行数据库访问与对象转换;

    1.设计表结构

    在mysql里添加个数据库WebService 并且添加个表结构User



    这里要注意下主键必须用id字段并且放在第一位,因为后面StORM会按一定的规则使用这个其他方式我还没有试,暂且使用这个方式吧,按上图的方式创建这个表并点击Apply;

    在代码main.swift中加入

    import MySQLStORM

    MySQLConnector.host = "localhost";

    MySQLConnector.username = “root”;//数据库用户名

    MySQLConnector.password = “000000”;//数据库密码

    MySQLConnector.port = 3306;//数据库端口

    MySQLConnector.database = “WebService”;//数据库名

    这样我们的程序就连接上mysql数据库了;

    下面我们创建个数据Model类



    import StORM


    class UserRegisterModel : MySQLStORM {

        var id : Int = 0;//这个id对应数据表结构里的主键,必须放到第一个

        var userName : String = "";

        var password : String = "";

        var loginTime : String = "";

        var registerTime : String = "";

        

        // The name of the database table

        override open func table() -> String { return "User" }//这个User就是要操作的表名

        

        override func to(_ this: StORMRow) {

            if this.data["id"] is Int {

                id = this.data["id"] as! Int;

            }

            else if this.data["id"] != nil {

                let id32 = this.data["id"] as! Int32;

                id = Int(id32);

            }//这里有个坑,StORM在转化的时候id会返回Int32类型,但很多方法使用的时候都只能转成Int类型,所以这里处理成转换为Int类型,若有更好的方法可提出来

            userName = this.data["userName"] as! String;

            password = this.data["password"] as! String;

            loginTime = this.data["loginTime"] as! String;

            registerTime = this.data["registerTime"] as! String;

        }

        

        func rows() -> [UserRegisterModel] {

            var rows = [UserRegisterModel]()

            for i in 0..<self.results.rows.count {

                let row = UserRegisterModel()

                row.to(self.results.rows[i])

                rows.append(row)

            }

            return rows

        }

    }


    添加个class


    class NetRequest {

        

    }


    class UserRegister: NetRequest {

        

        public static func requestHandler(request: HTTPRequest, response: HTTPResponse) {

            // need to make sure something is available.

            

            let userName :String! = request.param(name: "userName");

            let password :String! = request.param(name: "password");

            

            let user = UserRegisterModel();

            

            user.userName=userName;

            user.password=password;

           

            let registerTime : String = try! formatDate(getNow(), format: "%Y-%m-%d %H:%M:%S”);//这里有个方法可以处理时间,swift Perfect 对foundation框架有很多坑,这里都是用Darwin和SwiftGlibc

            user.registerTime = registerTime;

            try? user.find([("userName", userName)]);

            

            guard user.results.foundSetCount <= 0 else {

    //判断说明 该用户已存在

     response.sendData(data: ["code":100,"message":"用户名不存在"]);

                         return;

            }

            

            try? user.save(set: { (id) in

                user.id=id as! Int;//存储user数据到数据库里,并返回主键id,这里就有坑,若是id设置成int32类型,这里将不在走

            })

            

            guard user.results.insertedID > 0  else {

    //判断说明 注册是否成功(数据是否被插入数据库)

     response.sendData(data: [“code”:100,"message":"注册失败"]);

                return;

            }

    response.sendData(data: [“code”:200,”message”:"注册成功",data:user.asDataDict()]);

        }

    }





    下面代码是将Model转成json的代码





    extension HTTPResponse {

    func sendData(data : Any) -> Void {

            var encodedString : String! = "";

            do {

                encodedString = try data.jsonEncodedString();

            }

            catch{

                

            }

            self.appendBody(string: encodedString);

            self.completed();

        }

    }


     最后我们把这些代码与文件加入到工程里并在

    NetworkServer.swift文件里的initRoutes方法修改为

     func initRoutes() -> Void {

            routes.add(Route.init(methods: [.get,.post], uri: "/**", handler: handler));

            routes.add(Route.init(methods: [.get,.post], uri: "/api/register", handler: UserRegister.requestHandler));

        }

    这样我们的一个注册接口就完成了。


    启动服务, 在浏览器上调用http://localhost:8181/v1/api/register?userName=test&password=123456,这样我们将会看到返回的json数据了

    { code200, data: 
    { userName: 
    "test", loginTime: "2018-05-08 09:48:00", id6, registerTime: "2018-05-08 09:48:00" }, message"success"

    }

    可能会有不同,这里不做计较。这时我们本地的一个接口服务就算调试完成了,下节我们要将服务部署到服务器上。

    下面附上源码地址https://github.com/z123sen/perfectServer

    下一篇 https://blog.csdn.net/z123sen/article/details/80248667



    展开全文
  • http://www.itdaan.com/keywords/Show+NSMenu+next+to+NSButton+in+Swift+OSX.html http://www.itdaan.com/keywords/Swift+Mac+OSX+NSButton+title+color.html 1在SwiftOSX中显示NSButton旁边的NSMenu - ...

    http://www.itdaan.com/keywords/Show+NSMenu+next+to+NSButton+in+Swift+OSX.html

    http://www.itdaan.com/keywords/Swift+Mac+OSX+NSButton+title+color.html

    1SwiftOSX中显示NSButton旁边的NSMenu - ShowNSMenunext to NSButton in SwiftOSX

    2016年04月11 - How can i show a NSMenu next to my NSButton after the button was clicked. 单击按钮后,如何在NSButton旁边显示NSMenu。 This is what i have so far. 这就是我到目前为止所拥有

    2Swift Mac OSXNSButton标题颜色 - Swift Mac OSXNSButton title color

    2015年01月10 - I would like to know how to change title color to a NSButton in swift, I've seen lots of examples in objective-c but I think in swift

    3如何通过按NSButton显示键盘? - How to show a keyboard via press a NSButton?

    2010年12月08 - I only know few ways to show a keyboard on iOS 我只知道在iOS上显示键盘的几种方法 touch textfield,search bar,textview..... 触摸文本字段,搜索栏,textview ..... Is it can via

    4使用SwiftXcode 6中进行NSButton事件处理 - NSButton Event Handling in Xcode 6 with Swift

    2014年07月29 - I want to set the action and target for an NSButton in swift. In previous versions of Xcode, there were setAction and setTarget methods, but those

    5如果在swift中按下NSButton,则创建简单的动作 - creating simple action if NSButton is pressed in swift

    2016年06月10 - I am in the process of learning swift. I would like to know how to programmatically call a function if a button is pressed.... I tried

    6NSButton上悬停事件以显示图像 - Get hover event over NSButton to show an image

    2013年02月28 - So I am trying to make an application that has a button (doesn't have to be a button) that when you hover over it a pop-up window appears. I have been

    7显示文本结尾旁边的更多按钮Swift - Show more button next to end of text Swift

    2016年11月14 - answer in swift. After clicking on more button i want to show all the text. change the button to less. 如果空间不足,我想在文本末尾或下方显示更多按钮。我不明白Apple开发者是怎么做到的?请迅速回答。点击

    8SwiftOSX - IKImageView上设置NSImage - SwiftOSX - set NSImage on IKImageView

    2017年09月06 - ) imagemIKImageView.setImage(cgImagem, imageProperties: [AnyHashable : Any]) } } @IBAction func voltarButtonClicked(_ sender: NSButton) { dismiss(self) } }

    9拖放功能swiftOSX - Drag and drop function swiftOSX

    2016年05月08 - This is a bit complex but I hope that someone can help me. I am trying to build a drag and drop function for my OSX application. 这有点复杂,但我希望有人可以帮助

    10SwiftOSX NSImageView拖放 - SwiftOSX NSImageView Drag and Drop

    2017年09月04 - : NSProgressIndicator! @IBOutlet weak var salvarFornercedorButton: NSButton! var fornecedor: Fornecedor? var logoFornecedorSelecionada = false override

    11使用swift开发OSX应用

    2016年01月03 - Xcode,使用 File\NewProject… 菜单,在弹出窗口中选择 “OS X/Application”,然后Next。在接下来的窗口中,配置App信息。在product name栏中输入ScaryBugsMac,输入你的机构名以及机构ID。剩余字段保留为空白。选择Swift作为开发语言,保持所有

    12Swift中,处理单击和释放事件 - NSButton in Swift, handle click and release events

    2016年08月20 - actions because it doesn’t show its state; it always displays its normal image or title. This option is called Momentary Light in Interface Builder’s Button

    13如何为OSX快速分割图像? - How to split image with Swift for OSX

    2015年01月06 - 'm approaching it correctly. Here is what I have so far (to show the playground output, code attached at end): 我将一个2880 x 2560图像分割成两个1440 x 2560图像。我一直在

    14NSMenu委托不会触发menuWillOpen - NSMenu delegate does not trigger menuWillOpen

    2017年02月08 - I've got an Interface Builder NSMenu-Object. I added my custom Class "StatusBarMenu". 我有一个Interface Builder NSMenu-Object。我添加了自定义类“StatusBarMenu

    15使用SwiftOSX Statusbar App [重复] - OSX Statusbar App using Swift [duplicate]

    2014年06月10 - This question already has an answer here: 这个问题在这里已有答案: OSX status menu not working in Swift 1 answer OSX状态菜单在Swift 1中无效 I am

    16示例表视图不打印数组SwiftOSX - Sample TableView not print the array SwiftOSX

    2015年06月30 - I have the next code in my application but only print the next image,i don't know why.Someone who can help me solve this error.I think that the error

    17iOSOSX启动Swift REPL - Starting Swift REPL for iOS vs OSX

    2014年06月24 - How does one invoke the Swift REPL for iOS? I tried the command line argument of swift -sdk ... and have looked, via swift -h, at the other

    18使用SwiftOSX禁用睡眠/屏幕保护程序 - Using Swift to disable sleep/screen saver for OSX

    2016年06月02 - I'm looking for a way to disable sleep mode and screensaver through my application using Swift. I know this question has been asked before, but none

    19如何使用SwiftOSX获取MAC地址 - How to get MAC address from OSX with Swift

    2015年08月05 - Is it possible to get the MAC address using Swift? 是否可以使用Swift获取MAC地址? The MAC address being the primary address for the Wi-Fi or Airport. MAC地址

    20SwiftOSX音频在录制时通过 - SwiftOSX Audio pass thru while recording

    2017年08月17 - I'm programming in Xcode 9 - swift 4 - macOS NOT IOS 我用的是Xcode 9 - swift 4 - macOS而不是IOS I have a basic recording audio setup below for recording

    21Realm SwiftOSX Cocoapods示例应用程序崩溃 - Realm SwiftOSX Cocoapods sample app crashes

    2016年02月16 - My steps were: 我的步骤是: 1) In Xcode, I create a new command-line OSX Swift app and add their example "class Dog" code, plus "import RealmSwift

    22Swift中捕获OSX媒体控制按钮 - Capture OSX media control buttons in Swift

    2015年09月10 - but it is not working in combination with Swift: https://github.com/nevyn/SPMediaKeyTap 我知道这个可爱的库,但它不能与Swift结合使用:https://github.com/nevyn/SPMediaKeyTap

    23OSX状态菜单在Swift中不起作用 - OSX status menu not working in Swift

    2014年06月05 - anything. 但是,如果我尝试在swift中基本上做同样的事情,它什么都不做。 class AppDelegate: NSObject, NSApplicationDelegate { @IBOutlet var statusMenu: NSMenu; func

    24[电子] [OSX]始终显示托盘图标 - [Electron][OSX] Always show the tray icon

    2016年09月10 - I am writing an OSX App using Electron, and it primarily focuses on the tray. Basically, it only shows when the app is currently being used, how can

    25如何让osx shell脚本在echo中显示颜色 - How to get osx shell script to show colors in echo

    2015年02月28 - I'm trying to add color output to my errors in a bash script that I have running on a mac. The problem is the colors are not working. I created the si

    26如何用Swift iOS监听UIReturnKeyType.Next - How to listen for UIReturnKeyType.Next with Swift iOS

    2014年06月12 - When the user presses next on the keypad I want to move from the current UITextField to the next UITextField, the UIReturnKeyType is set

    27Swift中使用Tab键选择next NSTextView - Select next NSTextView with Tab key in Swift

    2016年03月15 - Is there a way to change the responder or select another text view by pressing tab on the keyboard, in Swift? 是否有一种方法可以通过快捷键上的tab来改变应答器或选择另一个文本视图

    28使用SwifttextFieldShouldReturnNext / Done按钮 - Next/Done button using Swift with textFieldShouldReturn

    2015年04月28 - subview (SignUpWindowView.swift), I set up each field with a function, as an example: 在我的signUpWindow子视图(SignUpWindowView.swift)中,我使用函数设置每个字段,例如: func

    29使用Swift 3OSX Sierra上使用EKEventStore访问日历的问题 - Problems accessing Calendar using EKEventStore on OSX Sierra with Swift 3

    2016年10月28 - This appears very simple, but I've been struggling for several days to get access to the Calendar on OSX. I have switched on the App Sandbox

    30从文件SwiftOSX简单读入字符串? [重复] - Simple read into string from file SwiftOSX? [duplicate]

    2015年12月31 - In the playground (Xcode 7, Swift 2.1) for OSX, this creates nothing but an empty string: 在OSX的操场(Xcode 7,Swift 2.1)中,这只会创建一个空字符串: let fileString = “/Users/me

    31使用swiftmailcore2 OSX中获取电子邮件正文 - Fetch an email body in mailcore2 OSX with swift

    2015年09月15 - I try use this class: MCOIMAPFetchContentOperation for fetch body mail. But i don't know how invoke her in swift and i don't know the arguments who

    32如何在osx上使用swift创建透明背景的窗口? - How can I create a window with transparent background with swift on osx?

    2015年12月30 - I want to create an osx/cocoa application on my mac, which does something very simple: Display a text string on my mac, with no background.

    33如何通过按钮操作(Swift 3)显示NSWindowMac OSX - How to make NSWindow appear from button action (Swift 3) (Mac OSX)

    2017年07月01 - I set the NSWindow as "hidden at launch". How do I make NSWindow appear (pop up) when a button is pressed? 我将NSWindow设置为“隐藏在发射时”。当按下按钮时,如何使NSWindow显示(

    34没有使用Swiftstoryboardxib文件的OSX应用程序 - OSX application without storyboard or xib files using Swift

    2015年03月01 - main的.swift文件。但我不知道在那里写什么(就像我需要autoreleasepool或类似的东西?)。例如,我将如何初始化NSMenu以及如何将NSViewController添加到活动窗口(iOS的类似.rootViewController没有帮助)。谢谢你的帮助 ;) Edit: I

    35OSX / Swift:屏幕可用时调用功能 - OSX/Swift: Call function when screen becomes available

    2016年01月04 - I want my OSX app to call a function when the user's screen becomes available, ex: their computer wakes from sleep or the user turns on their screen.

    36SwiftOSX - 从另一个类和线程更新NSTextView - SwiftOSX - update NSTextView from another class and maybe thread

    2018年05月22 - concepts. 我是Swift编程的新手,我的背景一直是程序语言,所以我要接受语言和一些OO概念。 I'm building an OSX application that has 1 GUI window, with 2 input fields and a button - when the button

    37如何从OSXSwift中的// URL获取电子邮件主题 - How to get e-mail subject from message:// URL in OSXSwift

    2016年06月14 - in flux at the moment and most examples show how to use it in iOS, I simply cannot find a way to set up my "Preview" object using a URL and get

    38为什么Swift 3OSX vs iOS构建的处理方式不同? - Why does Swift 3 treat NSString differently for OSX vs iOS build?

    2016年09月29 - I have a class that is shared by iOS and OSX. After upgrading to Swift 3, the following line of code: 我有一个由iOS和OSX共享的类。升级到Swift 3后,代码如下: let

    39如何显示关于td的旁边的响应 - how to show the response next to the regarding td

    2013年11月20 - when i clicking the forth button it reaponse is showing on the first td i want to show the response next to the regarding td below is my code can one

    40以编程方式创建NSTableView(无法显示NSHeaderView)(cocoa osx) - Programmatically creating an NSTableView (trouble getting the NSHeaderView to show up)(cocoa osx)

    2011年01月05 - I am making an NSTableView programmatically but for some reason no matter what I do, I cannot make the darn headerView show up. It is imperative

    41限制项目在菜单和显示时,单击next按钮 - Limit item in menu and show when click next button

    2017年02月24 - I have a menu have many items. 我有一份菜单有很多项目。 I want to show only 5 items, other items will be hidden. 我只想显示5个项目,其他项目将被隐藏。 When clicking next

    42在每次打开时修改NSMenu结构? - Modify NSMenu structure on each open?

    2011年03月13 - I need to be able to dynamically modify an NSMenu hierarchy each time it is shown (add/remove items etc). For example: 我需要能够在每次显示时动态修改NSMenu层次结构(添加

    43找到右键单击显示的NSMenu位置 - Find NSMenu position which was shown on right click

    2012年11月07 - In my app I have three NSImageView. When the user right click over the imageview, I am showing a NSMenu which two NSMenuItems "Add Photo", "Delete

    44swift的方式显示AM/PM - Show AM/PM in capitals in swift

    2015年07月17 - I wrote the following code to show a datetime in a particular format: 我编写了以下代码以显示特定格式的datetime: let formatter = NSDateFormatter

    45Swift 3中显示Facebook活动 - Show Facebook Events in Swift 3

    2017年06月02 - How can I store Facebook events in an array using Swift 3? I have the following code which I pretty much copied from The Swift Guy but it doesn't

    46swift中的alertController中显示textField - show the textField in the alertController in swift

    2016年06月08 - Just now I wrote the code which is provided below. I would like to produce the output for the following code but it crashes when I run it, and it show

    47Swift中的View上显示GoogleMaps - Show GoogleMaps on View in Swift?

    2015年09月07 - My code: 我的代码: var camera = GMSCameraPosition.cameraWithLatitude(currentLocation.latitude, longitude: currentLocation.longitude, zoom: 12) //latitu

    48Swift - 无法显示导航栏 - Swift - Unable to show Navigation Bar

    2016年01月24 - 控制器,从中有一个VC继承自UITableViewController(注释为VC1)。当我单击表中的一行时,它会转到另一个显示详细信息的视图(注释为VC2)。我希望在详细信息视图中显示导航栏,但事实并非如此。我尝试了以下选项: I tried to set the segue as Show

    49快速加载NSWebView OSX中的本地文件或URL,而不是UIWebView - Swift - Load Local File or URL in NSWebView OSX, Not UIWebView

    2014年08月03 - Ok, so been working on this issue for a while now, trying to load a local HTML file or URL to a web view in Swift for OS X not iOS. 好了,我们已经研究这个问题

    50带有圆角和背景颜色的NSButton - NSButton with round corners and background color

    2016年09月14 - 。:( EDIT: I'm asking about OSX 编辑:我问的是OSX

    51mouseEntered事件上的NSButton图像阴影 - NSButton image shadow on mouseEntered event

    2012年08月25 - I have a borderless NSButton that contains an image and is subclassed with my ButtonEffect class to detect mouseEntered and mouseExited events. My

    52NSButton如何为文本着色 - NSButton how to color the text

    2012年10月28 - on OSX I have an NSButton with a pretty dark image and unfortunately it is not possible to change the color using the attributes inspector. See

    53是否可以制作圆形NSButton - Is it possible to make a circular NSButton?

    2016年03月03 - I am trying to create a custom shape NSButton. In particular I am trying to make a round button, using a custom image. I've found a tutorial

    54如果NSTextfield不为空,则启用NSButton - enable NSButton if NSTextfield is not empty

    2016年08月04 - I am creating a OSX app and would like to enable a button when all textfield are filled. But do not have much experience with osx app as there seem

    55NSVutualEffectView上的NSButton:错误的背景颜色 - NSButton on NSVisualEffectView: Wrong Background Color

    2015年06月05 - I have a NSVisualEffectView within a NSPopover developed for 10.10. 我在为10.10开发的NSPopover中有一个NSVisualEffectView。 When subclassing the NSVisualEffectVi

    56C错误:free():无效的下一个大小(快速):C程序在OSX上的不同行为,Linux - C Error: free(): invalid next size (fast):, different behaviour of C program on OSX, Linux

    2014年08月21 - , which works perfectly on my OSX system (too huge to copy). I already tested it with Valgrind, and I am not missing any frees /mallocs /or writes, all

    57Swift以编程方式向按钮添加show动作 - Swift add show action to button programmatically

    2016年02月22 - how can I add action to button programmatically. I need to add show action to buttons in mapView. thanks 如何以编程方式向按钮添加操作。我需要在mapView中为按钮添加show动作。谢谢

    58GRDBSwift 3中使用rows.next()编译错误 - compile error with rows.next() in GRDB and Swift 3

    2017年07月25 - ]' has no member 'next'" 我正在使用Swift 3和GRDB SQLite库开发iOS应用程序。以下代码片段导致编译错误“类型'[Row]'的值没有成员'next'” let rows = try Row.fetchAll(db, sql, arguments:arguments

    59MacOS 上的 NSCell(比较NSButton NSButtonCell

    2017年09月08 - NSButton 和 NSButtonCell 的继承关系Cell和Control 的关系本文选摘自 关于NSCell : http://cocoa.venj.me/blog/about-nscell/NSButton 和 NSButtonCell 的继承关系NSButton的继承关系

    60改变NSButton字(title)的颜色

    2017年03月29 - 转自我的简书:http://www.jianshu.com/p/a9e86b79a2d4 NSButton不能像UIButton那样简单的修改title的颜色,或者说NSButton不能像UIButton那样做很多事,使用起来真的很不方便。 经过大量研究测试,终于发现一种修改文字颜色的相对来说

    61Xcode 6.1:在所有OSXSwift项目中突然没有这样的模块'cocoa' - Xcode 6.1: no such module 'cocoa' suddenly in all OSXSwift projects

    2014年10月29 - This is an OSX project, not iOS and the problem happens on all projects, including newly created ones. 几天来我一直在使用Xcode 6.1没有问题,但突然间我在所有Swift文件中都收到错误没有这样的模块'Cocoa

    62如何通过Swift中的URLScheme捕获用于启动OSX应用程序的URL - How to capture the URL used to launch an OSX application via URLScheme in Swift?

    2014年06月06 - I've been trying to replicate the usual way of doing this in Objective-c in swift for a new swift app I'm playing around with. 我一直在尝试复制通常在Objective-c

    63OSX/Swift:在建立/恢复互联网连接时调用一个函数 - OSX/Swift: Call a function when internet connection is established/restored

    2015年11月02 - What I want to do is call some code when the internet connection is established or restored. 我想做的是在建立或恢复互联网连接时调用一些代码。 I know there are solutions out

    64Swift 2 OSX如何在不进行身份验证的情况下成功进行会话? - Swift 2 OSX How come session with proxy succeeds without authentication?

    2016年07月18 - I'm making an NSURLRequest through a proxy host/port. It seems that the request is receiving the appropriate response. The only issue is that this pro

    65带有Swift Cocoa库的OSX命令行工具,未加载库 - OSX Command Line Tool with Swift Cocoa Library, Library not loaded

    2015年02月18 - (OSX) written in Swift. I'm using a Cocoa Framework (PriorityQueue) written in Swift. When I set EMBEDDED_CONTENT_CONTAINS_SWIFT to yes on the Framework

    66获取空指针异常,试图从OSX上使用swift从当前活动窗口获取边界 - Getting null pointer exception trying to get bounds from current active window with swift on OSX

    2016年07月24 - found similar Objective-C example that I converted the best I could to swift for my case (I'm really bad at Objective-C). 我正在尝试确定当前前景应用程序是否处于全屏模式(另一个应用程序

    67SwiftOSX - 设置值时,无法识别的选择器发送到NSObject子类上的实例 - SwiftOSX - Unrecognized selector sent to instance on NSObject Subclass when setting value

    2017年09月21 - 识别的选择器发送到实例0x6080000055a0 Action that calls the class 调用该类的操作 @IBAction func selecionarFotosButtonClicked(_ sender: NSButton) { let panel

    68HTML:为什么Android浏览器在键盘中显示“Go”而不是Next - HTML: Why does Android browser show “Go” instead of “Next” in keyboard?

    2011年07月01 - =文本(用户名输入) input type=password (password) 输入类型=密码(密码) input type=submit (Login button) 输入类型=提交(登录按钮) Why does the Android browser show "Go

    69Swift 2 AVPlayer -播放下一个视频 - Swift 2 AVPlayer - Play Next video Previous Video

    2016年03月30 - of videos. If the user makes it full-screen video, then previous and next player button enable , and play when they click. 我必须完成播放视频。我有一个视频列表。如果用户将它设置为全屏视频

    70SwiftARKit保存ARPlaneAnchor用于下一个会话 - Swift : ARKit Save ARPlaneAnchor for next session

    2017年07月25 - ARKit is quite new and I am quite new in swift... So I'm having some troubles... ARKit很新,我很快就开始......所以我遇到了一些麻烦...... I'd like to save

    71NSMenu阻塞定时器/全局事件监视器/ - NSMenu blocking timers / global event monitors / etc

    2013年03月05 - 不再起作用: To show the menu: 要显示菜单: [_menu popUpMenuPositioningItem:nil atLocation:point inView:nil]; My timer (called before the popup) is no longer

    72jQuery show-hide远近找到下一个元素 - jQuery show-hide find next element far and near

    2012年10月11 - This show-hide function attempts to do so anonymously, without the need to maintain unique IDs for the target divs. 此show-hide函数尝试匿名执行此操作,而无需为目标div维护

    73按顺序切换元素 - 显示一个,然后隐藏它并显示下一个 - Toggle elements in sequence - show one, then hide it and show the next

    2015年09月13 - Let's say we have 10 lights (we use li tag) . I want to show them one by one like this : 假设我们有10个灯(我们使用li标签)。我想像这样一个一个地展示它们: <h3>Light<

    74如何在单击按钮时显示下一篇文章 - How to shownext article on click of a button

    2014年09月16 - ').click(function() $(this).parents('div').next('article').show(); }); Now on click of the .continue button I need to hide the present article and show

    75datatables bootstrap分页 - 仅显示上一个/下一个 - datatables bootstrap pagination - only show previous / next

    2013年03月15 - , the DataTables table shows previous 1 2 3 4 5 next, and it's just chunky. How can I lose the numbers, and just have previoius next? 无论如何,DataTables表显示了之前

    76Array onClick中显示下一个图像 - Shownext image in Array onClick

    2017年09月11 - I am working on setting up images that can be clicked through with on screen arrows. Currently I have the images all showing up via a loop and an arra

    77ViewPager在屏幕上的项目预览之前和之前显示 - ViewPager shownext and before item preview on screen

    2015年06月01 - I want to show viewpager next and before page preview in screen. Before and next page show deep in screen and slide next page with deep animation.

    78如何在字段旁边显示错误消息 - How to Show Error Messages Next to Field

    2011年04月13 - I have a form with input fields/labels etc. How do I get the error message to show up next to the field? instead of clumped together at the top? 我有一个

    79在悬停时显示表格行旁边的元素 - Show element next to table row on hover

    2012年08月21 - What I'm trying to implement is when someone hovers over a table row, I want to show up-and-down arrows on the left side of the table (outside

    80如何以编程方式在ViewPager中显示下一个视图? - How to programmatically shownext view in ViewPager?

    2011年10月18 - I created a ViewPager and everything is working fine, however I want to have a previous next button outside of ViewPager which can be used

    81如何使用UIScrollView来显示下一个视图的边缘 - How to use UIScrollView to show edge of the next view

    2017年08月22 - I am new in ios development, i want to show edge of next view using scrollview initial i got help from this Link, here is my view hierarchy 1) I

    82如何使用下一页显示viewpager - How to show viewpager with next pages

    2016年12月28 - I want to show the next item in viewpager as a shadow that user select which would look like following image: 我想将viewpager中的下一个项目显示为用户选择的阴影,如下图所示

    83如何在下一个活动中显示文字和图像 - How can show text and image in next activity

    2018年08月01 - ) { // Toast.makeText(MainActivity.this, "You Clicked at " +web[+ position], Toast.LENGTH_SHORT).show(); String value=(String)grid.getItemAtPosition(i

    84如何在下一页显示插入数据 - How to show insert data in the next page

    2017年11月29 - I have two form. In the second page mobile no is not showing. 我有两种形式。在第二页中,移动设备没有显示。 echo $_r['mobile']; in the second form is showing nothing. echo

    85直方图和qqplot相邻,par -PDF中没有显示 - Histogram and qqplot next to each other with par - does not show in PDF

    2016年05月09 - (paired) par(mfrow = c(1,2)) If I look at "plots" it is perfectly fine and it shows these two perfectly next to each other. However, when I want

    86SQL Microsoft Access立即显示下一行 - SQL Microsoft Access Show immediate next row

    2015年10月30 - I'm trying to show rowa and rowb (right below it) if rowa is true in the WHERE statement. I do have it ORDER BY Date, but that wouldn't affect

    87mysql中显示从现在()到下7天的记录。 - Show records from now() till next 7 days in mysql

    2011年01月26 - I want to select rows from the datetime now till 7 days in the future, how can I do this? Read alot about the date function of mysql but cant figure i

    88jquery显示同一个类的下一个div ? - jquery shownext div of same class?

    2011年06月06 - () { $(".slides").parentsUntil(".slides").prev().show(); $('.slides').hide(); }); $('.next').click(function() { $(this).parentsUntil

    89SwiftShow modal over modal可能不会解散父级? - SwiftShow modal over modal possible without dissmiss parent?

    2017年07月11 - I´m currently testing some popover modals in my iOS App. I have a Dialog with displays a second Dialog on of it. I cal the second Dialog like this: 我目

    90Mac开发之如何设置NSButton高亮图片

    2017年09月05 - Mac开发之如何设置NSButton高亮图片iOS开发设置UIButton高亮图片非常简单,但Mac开发和iOS开发略有不同,在NSButton的setImage并没有设置 UIControlState的参数,因此要设置NSButton的高亮图片是要有一定波折的。这里讲两种方式设置button高亮

    91swift在谷歌地图上显示坐标 - Show co-ordinates on google map in swift

    2018年05月02 - ) break case .failure(_): print("error") break } } but I am unable to show it on the google maps. Honestly I

    92不会在swift中显示登录页面 - will not show login page in swift

    2017年09月03 - login button, i go to next page. now how can i say the app do not show login page for next running until i log out?? 当我点击登录按钮时,我转到下一页。现在我怎么能说应用程序不显示下次运行

    93swiftiOS根据条件显示警报动作 - swift: iOS show alert action depending to a condition

    2018年04月11 - I have my code below which trigger an alert but I want to trigger alert and show only actions depending on the condition for example in the condition

    94如何使用swift显示和/或隐藏子视图 - How do I show and/or hide a subview using swift

    2015年01月16 - So I've created a ViewControl in my storyboard that has 3 subviews. Each one represents a different view I want to show depending on which table row

    95如何在TableView中显示对象数组 - swift - How to show array of objects in TableView - swift

    2017年06月19 - [index]) return cell } } } So..i want to show in this line, only the DestinoInstancia.desDestino = dep.desDestino! 所以..我想在这一行显示

    96如何在swift中显示数组的所有元素? - How to show all the elements of an array in swift?

    2014年06月10 - I have an array like this: var array = ["Chinese","Italian", "Japanase", "French" , "American"] 我有一个这样的数组:var数组= ["Chinese","Italian", " japan "," Fre

    97想要在UIAlertControllerUIPopoverController Swift中显示UIPickerView? - want to show UIPickerView in UIAlertController or UIPopoverController Swift?

    2015年10月20 - I want to show UIPickerView in UIAlertController or UIPopoverController, I am new to iOS, please give me some example code here. 我想在

    98如何在Swift中将Gif显示到UIImageView中? - How to show gif into UIImageView in Swift?

    2014年06月30 - ; self.dataImageView.animationRepeatCount = 1; self.dataImageView.image = testImage.images.lastObject; [self.dataImageView startAnimating]; } Swift: var url : NSURL

    99Swift:强制显示Modal中的导航栏 - Swift: Force show Navigation Bar in Modal

    2015年02月09 - I have the following Storyboard Segue in my Swift project: 我的Swift项目中有以下Storyboard Segue: The animation is correct, but there is no navigation bar

    100Xcode SwifttableView中显示来自CloudKit的数据 - Xcode Swiftshow data from CloudKit in tableView

    2016年02月25 - Hope someone can help me. Im trying to show data (privateData) from CloudKit in a UITableview with prototype cell, but my code do bot show my data

    101Swift: UILabel如何显示所有文本 - Swift: UILabel how to show all text

    2015年06月12 - I am very new to Swift and I don't know how to make my UILabel show all text. 我对Swift很陌生,我不知道如何让我的UILabel显示所有的文本。 Here is how my label looks like

    102将键更改为true然后在swift中显示视图 - Change key to true then show view in swift

    2016年05月14 - OK, so I've added a view onto my Application that asks the user to accept or decline the Terms of Service. I have it so when they click accept, it cha

    103如何使用swift 4显示像facebook上传图像的collectionView - How to show a collectionView like facebook upload image using swift 4?

    2018年04月30 - Hello i want to show the collectionView exactly as the above image. I know that it responsible for UICollectionViewFlowLayout, but unable to do it.

    104Swift中的AppDelegate中显示警报[重复] - Show alert in AppDelegate in Swift [duplicate]

    2015年08月24 - This question already has an answer here: 这个问题在这里已有答案: How to show UIAlertController from Appdelegate 5 answers 如何从Appdelegate 5答案显示

    105如何在Swift中显示背景颜色的SDWebimage - How to show SDWebimage for background Colour in Swift

    2017年11月09 - SDWebImage is great library for conversion URL to image. Its working great. But, I have following issue SDWebImage是将URL转换为图像的绝佳库。它的工作很棒。但是,我有以下问题

    106从解析查询对象以使用swift显示为标签 - querying an object from parse to show as a label using swift

    2015年11月08 - I'm trying to query an object from Parse and I had it working with the old swift code but I'm getting an error now. 我正在尝试从Parse查询一个对象,我让它使用旧的swift代码

    107如何使用Swift打开Goog le地图以显示路线 - How to open Google Maps to show route using Swift

    2015年08月16 - I read around the Internet but couldn't find a legit answer. I need to open Google Maps when the user clicks a button to show directions. Start

    108如何显示所有注释调用Swift - How to show all annotations call out Swift

    2016年11月20 - I have an app which has a lot of annotations and I want to have their call outs open at the beginning(and if its possible never disappear). What I acc

    109如何在swift中以编程方式显示/隐藏UISearchBar - how to show / Hide UISearchBar programmatically in swift

    2018年03月13 - to do is show / Hide UISearchBar programmatically but I am not having the desire results. 我想要做的就是以编程的方式显示/隐藏UISearchBar,但是我没有得到想要的结果。 What I am trying

    110切换UITextField以在Swift中显示和隐藏 - Toggling UITextField to show and hide in Swift

    2016年10月11 - I'm trying to hide a username textfield when toggling over to login from register and show it again when toggling back. I'm programming the UI

    111在照片库(UIImagePickerControllerswift 4中显示取消按钮 - Show “Cancel” button in photo gallery (UIImagePickerController) swift 4

    2018年01月17 - In my AppDelegate.swift file I have this two lines: 在我的AppDelegate.swift文件中,我有两行: let barButtonItemMenu = UIBarButtonItem.appearance

    112在前台Swift 3中显示本地通知 - Getting local notifications to show while app is in foreground Swift 3

    2016年09月26 - to keep the optional func and xcode wants me to switch it to private. 我不知道这有多重要,但我不能保留可选的func和xcode让我把它改为private。 I'm trying to show the badge

    113如何通过SwiftXcode)上的代码显示屏幕? - How to show a screen through code on Swift (Xcode)?

    2018年08月21 - to show the second one from the first one. 我是Xcode的新手,我正在尝试为iOS构建一个应用程序。应用程序必须有几个屏幕(View Controller),但是当我尝试从第一个屏幕显示第二个屏幕时,我遇到了麻烦。 I want to show the second

    114swift中的AVPlayerViewControllerAVPlayer没有显示任何内容 - AVPlayerViewController and AVPlayer in swift doesn't show anything

    2015年12月18 - I'm trying to play an mp4 video from documents path in a AVPlayerViewController with an AVPlayer but it doesn't appear anything on screen.What am I do

    115键盘上的NSNotificationCenter Swift 3.0显示和隐藏 - NSNotificationCenter Swift 3.0 on keyboard show and hide

    2017年01月18 - I am trying to run a function when the keyboard shows and disappears and have the following code: 我正在尝试在键盘显示和消失时运行一个函数并具有以下代码: let notificationCenter

    116显示UIAlertController的简单App委托方法(Swift格式) - Simple App Delegate method to show an UIAlertController (in Swift)

    2014年10月29 - or didFinishLaunchingWithOptions and show a UIAlertView to confirm the user wants to import the data. Now that UIAlertView is depreciated I am trying to do the same thing

    117iOS SwiftLaunchScreen不显示图像 - iOS Swift: LaunchScreen doesn't show image

    2017年10月26 - Evening, my launch screen doesn't show the new images that I add in the assets. It displays only a black screen... Like if the image view isn't

    118通过单击Swift中的按钮显示/隐藏窗口 - Show/Hide Window by Clicking button in Swift

    2015年08月31 - I want to show/hide a window in swift by clicking a button from main window. Beginsheet is showing the window, but endsheet is not closing

    119Swift Navigation Controller在发布时显示 - Swift Navigation Controller show on launch

    2017年09月16 - 列表。 When user not logged in, then show the login page, otherwise show to list users page 当用户未登录时,则显示登录页面,否则显示列出用户页面 But when app launching

    120swift IBDesignable视图不在故事板中显示 - swift IBDesignable view not show in storyboard

    2014年11月06 - I want to custom a 5-star UIView,also I want it to be render in storyboard. So I decide to use @IBDesignable and @IBInspectable.The following is my co

    121如何在Swift中显示另一个类的警报? - How to show an alert from another class in Swift?

    2016年10月13 - ("Error", msg: "Could not add student to storage.") I then have this ErrorReporting.swift file: 然后我有这个ErrorReporting.swift文件: import Foundation class

    122如何只在Swift中显示UITextField的底部边框? - How to only show bottom border of UITextField in Swift

    2015年06月29 - I want to show only bottom border and hide the other sides. 我想只显示底部边框而隐藏其他边。 Output I see: As you can see I see the top, left and right borders also

    123Swift操场图像没有显示它应该是什么 - Swift playground image doesn't show what it should

    2014年10月07 - faced the following issues: 但我遇到了以下问题: The background exceed the rounded rect. 背景超过圆角矩形。 The gradient doesn't show. 渐变没有显示。 An image here:1 How

    124firebase存储中检索图像以在tableViewSwift)上显示 - Retrieve image from firebase storage to show on tableView (Swift)

    2016年06月20 - Extension question from New Firebase retrieve data and put on the tableView (Swift) 来自New Firebase的扩展问题检索数据并放在tableView(Swift)上 By moving

    125使用Swift在启动屏幕上显示app版本 - Show version of app in launch screen with Swift

    2015年11月07 - Scenario 场景 I want to show the version of my iOS 9 app made with Swift. 我想展示我的ios9应用的Swift版本。 What I did 我所做的 I know how to get the version (let

    126无法在Swift中的UIButton上显示图像 - Cannot get image to show on UIButton in Swift

    2015年12月31 - to the UIButton. I get the same result. Any ideas on how to make the image show on the device or simulator? 我一直在用这个工作几个小时,并努力寻找解决方案。我创建了一个UIButton并添加了一个渐变背层。我想要做的是在按

    127如何在swift中隐藏/显示按钮 - how to hide/show a button in swift

    2015年05月05 - I'm trying to have an if statement that will make a button hidden when a label displays a certain status, and appears when the label says something el

    128无法在swift中的UIImageView中显示* .gif文件 - Unable to show a *.gif file in a UIImageView in swift

    2015年10月20 - I have a *.gif file that I want to show in a UIImageView. I have tried the library FLAnimatedImage, code below. Result is just a static image. 我有一个

    129如何在tableview swift中显示Checkmark - How to show Checkmark in tableview swift?

    2016年11月24 - I have to show check mark before i selected for some array values, i have to show the checkmark for array value 1 and none for 0.How to do

    130Swift - 在页面滚动中隐藏/显示'tableHeaderView' - Swift - Hide/Show 'tableHeaderView' on page scroll

    2018年05月14 - I have a button in tableHeaderView of a tableView. I want to add an effect like the facebook search bar that hides / shows the button on page scroll.

    131如何从swift的当前日期开始接下来的10 - How to get next 10 days from current date in swift

    2015年03月05 - I have dateformat string like this "2015-03-09".How do i get next 10 days date from current date?any help will be appreciated.thanks in advance

    132如何安排一段代码在Swift的下一个runloop中执行? - How to schedule a piece of code to execute in the next runloop in Swift?

    2014年10月13 - :afterDelay:]. How can I schedule a piece of code to execute in the next runloop in Swift? 目前Swift中没有[NSRunLoop -performSelector:target: arguments:order:mode

    133如何在UipageViewController swift中预加载下一个和上一个视图 - how to preload next and previous view in UipageViewController swift

    2016年03月10 - the next and previous view controllers will resolve my issue of swipe delay. 由于经过大量的搜索和RND以及许多不同的代码实现之后滑动延迟的问题没有解决,所以我想预加载下一个和以前的视图控制器将解决我的滑动延迟问题。 how

    134如何通过Swift中的Segue将数据传递给下一个View - How to pass the data to next View via Segue in Swift?

    2016年08月10 - I am developing in Swift. 我在Swift开发。 And the following picture is my storyboard. 以下图片是我的故事板。 There has a Main view. The Main view will change

    135如何摆脱Swift导航后退按钮旁边的文本? - How can I get rid of the text next to the navigation back button in Swift?

    2017年11月14 - How can I get rid of the text and just have the back arrow show up for ALL view controllers that show up on the navigation stack. 如何摆脱文本,只显示导航堆栈中显示

    136Swift中下一个可用日期的日期格式[重复] - Date formatting for next available date in Swift [duplicate]

    2017年09月17 - with is restricted. 我目前正在从运行联盟的第三方网站下载体育应用程序的夹具列表,因此我必须处理的数据受到限制。 I'm trying to implement a feature that displays the next upcoming fixture. My problem is the dates

    137如何使用复选框和.next()在表单中显示/隐藏/切换div - How to show/hide/toggle a div within a form using checkboxes and .next()

    2012年10月09 - I am trying to toggle a div using jquery - basically want to hide part of a form and only show it when a user selects a particular checkbox. 我正在尝试使用

    138xcode中运行时使用NSTask工作的Swift 2.1 OSx shell命令,但在导出时不使用 - Swift 2.1 OSx shell commands using NSTask work when run from xcode, but not when exported

    2016年03月07 - I wrote a simple OSx (10.11) application to execute shell commands when a button is pressed. It works when I run it from xcode, but when I export

    139如何以编程方式单击NSButton时关闭NSViewController - How to dismiss NSViewController when NSButton is clicked programmatically

    2016年02月23 - How can I dismiss a NSViewController when a subview NSButton is clicked? 单击子视图NSButton时,如何解除NSViewController? I can't access to NSViewController

    140[Cocoa]_[初级]_[鼠标移动到NSButton上面和移开NSButton时,控件背景颜色的变化]

    2015年02月05 - /Foundation.h>@interface MqjNSButton : NSButton{ NSImage *image; }@property (readonly) NSImage *image;-(void)setImage:(NSImage *)imageTemp;@end源文件

    141cocoa开发之:自定义NSButton,NSButton添加鼠标移入移出效果

    2016年03月17 - 一直感觉在cocoa开发下的NSButton没有在ios开发下的UIButton使用起来方便,简单!但是还是需要自己去研究,通过各种自定义来实现想要的效果!接下来,我会以向NSButton添加鼠标移入移出效果为例,给大家简单的介绍下如何实现自定义NSButton!首先新建工程,然后创建继承于系统

    142如何使NSButton标题在底部居中? - How to make NSButton title at bottom and centered?

    2015年09月06 - How can I make a button's title at bottom and centered programmatically? 如何以编程方式在底部和居中创建按钮的标题?

    143NSButton - 在禁用模式下设置文本颜色 - NSButton - set text color in disabled mode

    2011年06月16 - For some reason, when my button is disabled, the text color turns white. I want it to stay black - how can i do that? 出于某种原因,当我的按钮被禁用时,文本颜色变为白色。我希望它保持

    144保留NSTimer,不保留NSButton操作 - NSTimer is retaind and NSButton action is not retained

    2014年07月17 - My question is why 我的问题是为什么 [myButton addTarget:self action:@selector(myAction) forControlEvents:UIControlEventTouchUpInside]; it is not retain and

    145NSAnimationContext不会对NSButton的帧大小进行动画处理 - NSAnimationContext does not animate frame size for NSButton

    2016年09月21 - works as expected for some view types (including NSImageView). However, it does not work as expected for an NSButton unless I add an explicit frame size

    146如何找出我是一个带按钮类型NSSwitchButtonNSButton - How find out if I'm an NSButton with buttonType NSSwitchButton?

    2012年10月17 - I'm subclassing NSButtonCell to customize the drawing (customizable theme). I'd like to customize the way checkboxes and radio buttons are drawn. 我将NS

    147NSButton NSTrackingArea - 跟踪不起作用 - NSButton NSTrackingArea - tracking doesn't work

    2012年09月15 - I'm trying to complete button highlighted on mouse over event. So I subclassed NSButton, where is put NSTrackingArea and methods - (void)mouseEntered

    148[Cocoa]_[初级]_[鼠标移动到NSButton上面和移开NSButton时,控件背景颜色的变化]

    2015年02月05 - ;Foundation/Foundation.h> @interface MqjNSButton : NSButton { NSImage *image; } @property (readonly) NSImage *image; -(void)setImage:(NSImage

    149如何将图像设置为NSButton以与按钮一起调整大小? - How to set an image to a NSButton to be resized along with the button?

    2013年03月31 - cell] setImageScaling:NSImageScaleAxesIndependently]; but the image gets distorted and loses quality. How can I do this on OSX? Thanks! 我有一个图像(3宽x 15高

    150创建的隐式NSButton没有正确显示 - Created recessed NSButton not displayed correctly

    2013年05月22 - I just created some basic NSRecessedBezelStyle NSButton programmatically, the codes are listed below: 我刚刚用编程的方式创建了一些基本的NSRecessedBezelStyle NSButton

    151NSToolbar项目中的NSButton:单击问题 - NSButton in NSToolbar item: click issue

    2013年08月09 - I want to use a NSButton configured to show only an image in my NSToolbarItem. The item is created in IB and the code to add the button to it is: 我想

    152Objective-cNSButton setAction不起作用 - Objective-c: NSButton setAction not working

    2011年09月09 - ,但我似乎无法让它工作。 In my AppController.h I have this code: 在我的AppController.h中我有这个代码: ... IBOutlet NSButton* btnZoomIn; IBOutlet NSButton* btnZoomOut

    153如何用动画改变NSButton的状态? - How to change an NSButton's state with animation

    2015年01月15 - animation (like when you click on it) when the corresponding boolean property in my model changes. Is there any method in NSButton that does this? I'm looking

    154基于视图的NSTableView - NSButton子视图不会触发 - view based NSTableView - NSButton subview not firing

    2013年07月22 - in the application delegate. However, if I place a NSButton in a regular view and do the same (hookup its action/target to call fire:) then it works. NSTableView中的按钮

    155NSButton默认按钮,带蓝色外观 - NSButton default button with blueish look

    2009年03月30 - I have a dialog with 1 or more buttons and want to be able to programmatically set the rightmost one be the default one, so that when the user presses

    156Rails:“下一个post”先前的post”链接在我的show视图中,如何? - Rails: “Next post” and “Previous post” links in my show view, how to?

    2009年08月14 - I'm new in Rails... smile 我是新在Rails中…微笑 In my blog aplication I want to have a "Previous post" link and a "Next post" link in the bottom of my show

    157iPhone 6 PlusaccessoryView旁边的UITableViewCell中显示了奇怪的行 - iPhone 6 Plus show strange lines in UITableViewCell next to the accessoryView

    2015年10月19 - I have a UITableView that is showing some strange thin grey lines next to the accessory view. This ONLY happens on the plus, no other iPhone shows

    158如何在xml文件中显示文本旁边的图标? - How can I show an icon next to Text in xml file?

    2013年08月12 - I tried to code like this 我试着这样编码 <ImageView android:id="@+id/ivIcon" android:layout_width="wrap_content" android:layout_height=

    159如何让Slider在跨度点击时显示下一个或上一个 - How to get Slider to shownext or previous on span click

    2015年10月19 - they're supposed to do, but when I click the span arrows, it doesn't go to the next or previous image. 当我单击图像缩略图时,它们会执行它们应该执行的操作,但是当我单击跨度箭头时,它不会转到下一个或上一个图像

    160knitr:如何显示彼此相邻的两个不同大小的图? - knitr: How to show two plots of different sizes next to each other?

    2012年12月21 - I wanted to generate two images of different sizes, but show them side-by-side. Is this possible? 我想生成两个不同大小的图像,但是并排显示它们。这可能吗? This works

    转载于:https://www.cnblogs.com/sundaymac/p/10333976.html

    展开全文
  • 【导语】Swift 自发布以来就备受众多 Apple 开发者关注,但由于 API 尚不稳定,系统没有内置 Framework 导致 App 包增大等问题,使得线上主力使用的公司还很少,不少客户端开发者都还没有机会使用 Swift 进行开发。...

    【导语】Swift 自发布以来就备受众多 Apple 开发者关注,但由于 API 尚不稳定,系统没有内置 Framework 导致 App 包增大等问题,使得线上主力使用的公司还很少,不少客户端开发者都还没有机会使用 Swift 进行开发。等到 2015 年 12 月 Swift 开源并正式支持 Linux 系统,广大 Apple 开发者迎来了更广泛的开发场景,可以用它来进行服务端开发。不到一年时间各种 Server-Side Swift Web Framework 相继问世,其中以 Kitura、Perfect、Vapor、Zewo 最为成熟。


    文章正式开始前,我们先对当前几款主流框架进行了解与对比。

    Kitura 是 IBM 推出的框架,使用 IBM Cloud Tools for Swift 管理组件依赖,并支持部署代码到 IBM 的云服务 Bluemix。另外还有一个在线 Swift 编码网站,可以看作是线上 GUI 版本的 Swift REPL,开发者可以直接在 Web 上编写代码并查看输出。Kitura 整个产品从代码编写到部署全部包揽,提供了完整的生态环境。

    Perfect 拥有 GitHub 上最多的 Star,各种功能组件和数据库连接工具也最为齐全。近期推出的 Perfect Assistant 是运行在 macOS 上的管理工具,同样支持组件依赖管理,自动化代码部署(支持 AWS、Azure),并通过调用本地 Docker 的方式实现了在 macOS 上编译 Linux 产物的功能。

    Vapor 以其友好的文档和 Pure Swift 代码实现著称,其 HTTP Parser 是使用 Swift 编写实现,而不像 Kitura 和 Perfect 是用 CHTTPParser 封装,这对最终的服务性能有很大影响。Vapor 还开发了命令行工具对 SPM 进行封装,好处是开发体验更好,但提高了学习成本。另外 Vapor 比较早就做了 ORM 工具 Fluent,整体感觉十分技术范、小清新。

    Zewo 是一系列开源组件的集合平台,特点是使用 libmill 实现了类似 Go 的协程功能,模块化的设计也不同于其他的框架。

    这些框架在各具特色的前提下都有高性能、易扩展等优点。正好部门内部有一个信息管理平台项目,需求很简单,只要有基本的增删改查就行,于是不用麻烦后端同学排期,可以自己来开发,也算是提前实践 Swift,积累经验。

    正式开发是在 2016 年 8 月,彼时 Swift 3 尚未发布,Beta 版本的 Toolchain 每周都在更新,框架也在积极跟进发布支持最新版本的 Toolchain。技术选型期间我先后尝试了 Kitura、Vapor 和 Perfect。Kitura 的整套产品耦合太紧密,用起来比较重,对于轻量级小项目并不合适。Vapor 一开始用起来很愉快,但写到数据库连接工具时一直无法连接成功,再加上当时还在 Beta 版本,问题不少也被弃用。最后,使用 Perfect 完成了项目研发。接下来,本文将着重介绍如何使用 Perfect 完成一套 RESTful API 的开发,希望能够对大家进行 Swift Server 端开发有所裨益。

    在编写代码前,要先了解目前开源的 Swift 项目包括了 Swift、SPM 以及配套的编译调试工具,在核心库方面有 libdispatch、Foundation、XCTest 这三个项目。在客户端开发中,Foundation 是最常用的工具库,它提供了一系列国际化、系统无关的 API。服务端项目增加 Foundation 支持可以统一开发体验和复用客户端代码,尤其是和系统无关的 API 可以大大增加可移植性,本属于 Swift 3.0 的组成部分但至今并没有开发完成,原因在于 Foundation 中用到了一些 Objective-C Runtime 的代码,而这部分代码并不在开源范围之内。于是在开发中需要用到 Foundation 库时就会碰到不少问题。

    环境配置

    macOS 上依然是 Xcode 搞定一切事情,Linux 上目前只支持两个版本的 Ubuntu,所以推荐使用 Docker 搭建 Swift 编译和执行环境,这样可以支持所有 Linux 系统,也方便在 Swift 快速迭代时及时更新 Toolchain。代码都用 SPM 管理,在实际使用中还是有些问题,比如不支持 MySQL 5.7,创建工程文件配置时漏掉了编译设置,寻找公共代码库路径在不同操作系统上没有适配等。

    开发中使用了两个第三方库 SwiftLog 和 MySQL-Swift。SwiftLog 支持自定义日志级别和增量写入的日志文件,并使用了喵神的 Rainbow 在 Linux 环境下输出彩色日志。MySQL-Swift 支持 MySQL 连接池复用,可以提高访问数据库的性能。

    部署环境使用 CentOS 作为宿主机,开启两个 Docker 实例分别运行 Perfect 和 MySQL,两个 Docker 实例通过 link 方式实现通信。使用 link 参数运行 Docker 实例,主 Docker 的 hosts 文件会增加从 Docker 的 host 信息,从而达到通过 Docker 别名进行通信的效果。初始化 MySQL 容器时可以将数据库文件路径设置到虚拟卷中,再使用 crontab 执行定期任务运行 AutoMySQLBackup 来备份数据。

    编码

    先初始化工程,使用 swift package init 新建工程,此时会生成 Package.swift 配置文件和源代码、测试代码目录。在 Package.swift 中添加 Perfect、SwiftLog、MySQL-Swift 后执行 Swift Build 即可拉取所有依赖代码。此时的目录并不包含 Xcode 工程文件,需要再执行命令 swift package generate-xcodeproj 生成,工程中各个依赖库的配置都通过自身的 Package.swift 配置文件读取。 
    SPM 不仅是去中心化的包管理器,它还可以编译出可执行文件,我们甚至能够直接在服务端编写代码并编译运行。如果说在使用 Objective-C 开发时用 Xcodebuild 开发自定义打包工作流,那么开发 Server-Side Swift 就需要使用 SPM 在服务端实现编译、打包等流程。虽然在服务端目前还有些兼容问题,但 SPM 作为 Swift 的组成部分,一直在快速改进与提高。

    然后,添加 API 路由,我们先添加路由配置,后面再将所有配置一起设置到 Server 对象上。Perfect 的路由 API 设计参考了 Express,只需要设置 HTTP 请求类型、路由地址和对应的处理函数即可,支持使用通配符与参数,用起来还算简洁。我们可以先设置基础 API 路径,再通过 Routes().add 方法添加自定义路由,这样所有的路由都被添加到指定 API 路径下。最后将路由对象输出一下,这样开启服务时会将所有注册的路由输出到日志。

    func makeURLRoutes() -> Routes {
        var routes = Routes()
        var apiRoutes = Routes(baseUri: "/api")
        var api = Routes()
        api.add(method: .get, uri: "/staff/{id}", handler: fetchStaffById)
        apiRoutes.add(routes: api)
        routes.add(routes: apiRoutes)
        SLogWarning("\(routes.navigator.description)")
        return routes
    }
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    Swift 没有 define 关键字,但可以通过 typealias 自定义类型名称,比如 Perfect 里的路由处理回调函数就被定义为 public typealias RequestHandler = (HTTPRequest, HTTPResponse) -> ()。从定义可以看到,响应函数有两个参数,HTTPRequest 包含了客户端请求的所有信息,包括 HTTP headers 和 content data。HTTPResponse 包括 HTTP headers、body 以及 HTTP Status,这些属性可以在函数中赋值并返回给客户端。

    接着来实现路由函数。先将请求参数拿到,将参数进行错误处理后调用数据库工具方法获取信息,并根据获取数据的成败做对应的处理,最后返回 JSON 格式的结果。

    在路由处理函数最后都需要调用 response.completed()方法通知 Server 回调处理完成,由于函数有几个结束点,在参数错误或者获取数据的时候都可能抛出异常并提前结束函数,所以需要在好几个地方执行 response.completed()方法。Swift 和 Golang 一样拥有 defer 关键字,我们可以在函数中使用它来完成资源回收或这种需要多处调用的代码。

    defer {
        response.completed()
    }
    • 1
    • 2
    • 3

    进行数据库请求和生成 JSON 返回值的操作都有可能抛出异常,这样在 do-catch 中会抛出两种类型的异常,我们可以使用 switch-as 语法针对不同类型的异常进行处理。

    do {
        let staffData = try StaffDataBaseUtil.sharedInstance.searchStaffByID(idString)
        try response.setBody(json: jsonBody(errorCode: returnCode, data: ["staff": staffData]))
    } catch let error {
      switch error {
        case let error as QueryError:
            // 数据库请求出错
        default:
            // 服务端出错
      }
    }
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    Perfect 并没有使用 SwiftyJSON 之类的第三方库,而是自己实现了很好用的 JSON 扩展,对常用的数据类型增加了 JSON 序列化和反序列化方法,Swift 的 Extension 在这里得到了充分的使用。

    extension Dictionary: JSONConvertible {
        /// Convert a Dictionary into JSON text.
        public func jsonEncodedString() throws -> String {
            var s = "{"
            var first = true
            for (k, v) in self {
                guard let strKey = k as? String else {
                    throw JSONConversionError.invalidKey(k)
                }
                if !first {
                    s.append(",")
                } else {
                    first = false
                }
                s.append(try strKey.jsonEncodedString())
                s.append(":")
                s.append(try jsonEncodedStringWorkAround(v))
            }
            s.append("}")
            return s
        }
    }
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22

    数据获取需要进行数据库请求,我们使用 MySQL-Swift 作为数据库连接工具,为的是使用连接池复用连接,但也给自己挖了个坑。在 Mac 上开发时都没有问题,但在服务器端就编译失败,后来发现有一部分的代码还不支持 Linux,原来是时区的问题。在连接数据库时需要传入一个 config,包括数据库地址、端口、密码等,其中就有时区配置。在从数据库获取数据时,如果字段中有日期类型,就会将获取的绝对时间转换为对应时区的时间字符串。在日期类型数据的处理部分用到了 NSTimezone,但这一类型在 Linux 上没有实现,于是编译失败。修复的方式很简单,使用 CFTimezone 传递信息就好,但 CFTimezone 返回的类型是 CFString,于是又要针对 macOS 和 Linux 实现不同的 CFString 转换到 String 的代码。如果 Swift 有一套跨平台的 Foundation 就不会出现这个问题了。

    MySQL-Swift 底层使用的是 CMySQL 库进行连接。根据 options 初始化数据库连接,将连接保存到连接池中,这样后续的数据库操作不需要再次重新连接数据库。再对每个连接对象添加是否正在使用的标记,如果当前连接池中的所有连接都在使用当中,则再次新增一个数据库连接对象进行操作。可以手动设置连接池的最大连接数,当连接池中的连接数到达最大连接数时,后续的请求将会抛出获取数据库连接失败异常。 
    MySQL-Swift 将查询方法封装的十分优雅,工具类在初始化时候根据提前设置好的 config 生成连接池,再调用 pool.execute 方法,并传入查询执行的闭包就行。这里用到了高阶函数和范型,语法简洁又安全。使用的时候不需要关心数据库连接对象的创建和状态,只需要直接使用闭包里传进来的 Connection 连接对象进行查询即可。

    private init() {
        pool = ConnectionPool(options: DBConfigOption)
    }
    let result: [Staff] = try pool.execute { conn in
        try conn.query(querySQL)
    }
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    对于同名不同返回值的函数,Swift 会针对代码中返回值的类型推断进行分析,确定最终运行时调用哪一个函数。上面 conn.query 函数就会根据不同的返回值执行不同的函数,所以在编写上面代码的时候一定要显示的声明返回的是 Staff 数组,不然函数返回的结果就会不同。另外在 query 的实现中可以看到,最后的不同返回结果是从同一个函数返回的 tuple 中拿到的,这样的代码阅读起来很有效率。

    public func query<t: queryrowresulttype="">(_ query: String, _ args: [QueryParameter] = []) throws -> ([T], QueryStatus) {
        return try self.query(query: queryString)
    }
    
    public func query<t: queryrowresulttype="">(_ query: String, _ args: [QueryParameter] = []) throws -> [T] {
        let (rows, _) = try self.query(query, args) as ([T], QueryStatus)
        return rows
    }
    
    public func query(_ query: String, _ args: [QueryParameter] = []) throws -> QueryStatus {
        let (_, status) = try self.query(query, args) as ([EmptyRowResult], QueryStatus)
        return status
    }</t:></t:>
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    拿到数据后可以将结果转换为自定义的数据类型。这里会将数据库查询结果解码为定义了默认值的结构体,并提供序列化方法给路由处理函数。

    static func decodeRow(r: QueryRowResult) throws -> Staff {
        return try Staff(
            id: r <| 0,
            name: r <| "name",
            department: r <| "department",
            timestamp: r <| "timestamp"
        )
    }
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    在开发完成后的测试中发现返回数据的时间戳总是差几个小时,但是直接查看数据库里的数据,时间戳又是正确的,于是一步步从获取数据到返回 response 调试看看哪里出的问题,最后发现是 Swift 时区没有自动设置为和系统相同,而一直是 UTC 时间,在生成时间戳文案的时候就出错了。

    所以在使用 Dateformatter 的时候需要手动设置时区,这也是 Foundation 的一个坑。

    func resultDic() -> Dictionary<string, any=""> {
        let dateFormatter = DateFormatter()
        dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
        dateFormatter.timeZone = TimeZone(identifier: "Asia/Shanghai")
        let dateString = dateFormatter.string(from: timestamp.date())
        return Dictionary<string, any="">.init(dictionaryLiteral:
            ("id", id),
            ("name", name),
            ("department", department),
            ("timestamp", dateString)
        )
    }</string,></string,>
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    在拿到数据后,可以将 HTTP Response 包装一下,在每个返回结果中都包括错误码,数据和时间戳这三个字段,并增加错误码对应的错误提示。这样不用在每个路由处理函数的最后都手动写一次。

    public func jsonBody(errorCode: ErrorCode, data: Dictionary<string, any="">?) -> [String: Any] {
        var body = [String: Any]()
        body["s"] =  ["code": errorCode.rawValue, "desc": errorCode.description]
        if let jsonData = data {
            body["data"] = jsonData
        }
        body["t"] = UInt(Date().timeIntervalSince1970)
        return body
    }</string,>
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    至此代码基本编写完成,为了方便调试,我们可以通过 Perfect 的 Filter 方法添加自定义日志,将每次的 HTTP 请求和返回的信息输出。这样我们不需要在每个路由处理函数中调用日志方法就可以输出所有请求的参数和最终返回的结果。

    func incomeMiddleware(request: HTTPRequest) {
        SLogInfo("Request URL: " + request.uri)
        SLogInfo("Request Method: " + request.method.description)
        SLogVerbose("Request Params: " + String(describing: request.params()))
        for (name, detail) in request.headers {
            SLogVerbose("Request HEADER: " + name.standardName.uppercased() + " -> " + detail)
        }
    }
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    我使用的 SwiftLog 作为日志工具,没想到在部署测试的时候也出了问题,表现为开启服务的时候可以输出日志,一旦请求进来就崩溃,抛出 Segmentation fault。但是代码在开发机上运行正常,一路调试下来发现是 “(Date())” 的问题,这段代码第一次执行没问题,第二次执行就会导致崩溃。直接在服务端用 REPL 执行两次 pring(Date())也发生了相同的崩溃。推断应该是 Date 对象的 description 代码执行出错,于是自定义 Date 对象的 description 方法,避免调用自带的方法,问题解决。

    所有配置和路由函数开发完成后,开始设置 server 对象。Perfect 支持静态文件路由,可以设置静态文件的路径。这里推荐针对 macOS 设置静态文件路径单独设置,因为 Xcode 编译出的可执行文件并不在代码目录,因此在本地调试时候会出现找不到静态文件的问题。

    #if os(OSX)
    server.documentRoot = "~/webroot"
    #elseif os(Linux)
    server.documentRoot = "./webroot"
    #endif
    • 1
    • 2
    • 3
    • 4
    • 5

    代码开发完成后,使用 Docker 初始化 Swift 实例并拉取代码,使用 swift build -c release 生成可执行文件,将可执行文件和 libCHTTPParser.so、libCOpenSSL.so、libLinuxBridge.so 三个依赖库文件复制出来提交到目标 Docker 中即完成部署。目前 Swift 官方只支持 Ubuntu 系统,也有人尝试在 CentOS 上手动编译 Swift 源码,但由于缺少官方的全面测试所以不推荐在生产环境使用。

    总结

    Swift 作为服务端开发语言的新成员,有着不少的先天优势,比如智能的类型推导、强大的协议扩展、丰富好用的语法糖,这也是官方宣传的 Safe、Fast 和 Expressive 的具体体现。开源后的 Swift 吸引了更多的开发者参与其中,从 4.0 演进表也可以看到更多强力且有趣的功能包括反射、并发、稳定的 ABI 等。未来是美好的,现实是残酷的,以目前国内的 Swift 开发生态环境,在客户端尚且无法占据主流位置,更不用想挑战 Java、PHP、Python 等语言在服务端的地位。想要用 Swift 替代各大公司线上成熟的开发方案是不现实的,但可以从小做起,从辅助工具之类的角度着眼,先做出广泛使用的产品,逐步找到自己的定位,再扩展使用场景。私以为 Go 在这方面做的很好,Docker 的流行让更多人知道了 Go 这门语言且证明了其实力。

    目前看来 Swift 最需要解决的是 ABI 稳定性和跨平台兼容两大问题,对于 ABI 来说,之所以到 3.0 版本还没有稳定下来,是开发小组认为目前稳定 ABI 将无法去掉现有实现中错误的部分,且很可能带着补丁开发后续版本将成倍提高今后的开发难度。越早提交的代码留存率越低。这对于语言的开发是件好事,不用带着很多历史包袱开发新功能。但对于开发者来说这意味着在语言的新版本发布后不能方便的快速跟进,除非所有依赖的 Swift 代码库都及时跟进并发布基于新版本编译的代码库,这会大大降低使用 Swift 开发的积极性。

    另外 Server-Side Swift 目前只支持 Ubuntu 系统,Foundation 的移植也还在进行当中,并且各种兼容 Bug 频出,在开发过程中很容易遇到开发环境和部署环境运行效果不同的情景。好消息是针对后面的问题,Swift 开发团队成立了 Server APIs Work Group,工作组的目标就是提供服务端跨平台 API,消除平台相关代码差异,提供基础框架功能代替 C 库的引入,进一步降低服务端的开发门槛,提高客户端代码的可移植性。同时 Swift 3.1 的修改内容中明确说明了会改进 Swift on Linux 和 SPM 的质量,期待 2017 年春天发布的这个版本会给 Server-Side Swift 带来显著的改进。

    展开全文
  • CoreData清空数据库 清空数据库可以使用删除文件的方式 通过沙盒路径进入到沙盒可以看到数据库文件有三个,我们逐一删除便可 代码中的kFileName是一个宏 表示创建的数据库文件名 NSF


    CoreData清空数据库

    • 清空数据库可以使用删除文件的方式

    • 通过沙盒路径进入到沙盒可以看到数据库文件有三个,我们逐一删除便可

    • 代码中的kFileName是一个宏 表示创建的数据库文件名




      
       NSFileManager *fileManager = [NSFileManager defaultManager];
      
              NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
      
      
          //沙盒中三个文件
              NSString *filePath1 = [documentsPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.db",kFileName]];
          NSString *filePath2 = [documentsPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.db-shm",kFileName]];
          NSString *filePath3 = [documentsPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.db-wal",kFileName]];
      
              NSError *error;
      
              BOOL success = [fileManager removeItemAtPath:filePath1 error:&error];
              [fileManager removeItemAtPath:filePath2 error:nil];
              [fileManager removeItemAtPath:filePath3 error:nil];
      
              if (success) {
      
                  NSLog(@"Remove fiel:%@ Success!",kFileName);
      
              }
      
              else
      
              {
      
                  NSLog(@"Could not delete file -:%@ ",[error localizedDescription]);
      
              }

      
      

      CoreData清空数据库实际开发中注意事项


      1.从原则上来讲,清空数据库时直接删除数据库文件的效率和便利性远大于先从数据库中取数据然后逐一删除
      2.但是虽然删除了数据库文件,继续从CoreData Stack技术栈堆中查询数据仍然可以查询到,这是因为在上一次的查询过程中,数据库中的数据已经被缓存到内存。
      3.网上有很多示例,要想清除CoreData缓存,ARC下直接设置CoreDataStack元素为nil

      kManagedObjectContext.managedObjectContext =nil;

          kManagedObjectContext.persistentStoreCoordinator =nil;

          kManagedObjectContext.persistentStore =nil;


      我认为这样写是不专业的,如果需要再次使用就必须要重新初始化CoreData Stack,非常损耗性能


      4.由于之前讲解过CoreData Stack中真正进行储存数据操作的是NSPersistentStore(存储器),所以这里只需要移除存储器再重新添加便可


       NSURL *url = [[kManagedObjectContextgetDocumentsUrl]URLByAppendingPathComponent:@"mysql.db"isDirectory:YES];

          NSLog(@"%@",kManagedObjectContext.persistentStoreCoordinator.persistentStores);

          [kManagedObjectContext.persistentStoreCoordinatorremovePersistentStore:kManagedObjectContext.persistentStoreCoordinator.persistentStores[0]error:nil];

          [kManagedObjectContext.persistentStoreCoordinatoraddPersistentStoreWithType:NSSQLiteStoreTypeconfiguration:nilURL:urloptions:nilerror:nil];


      [self.tableViewreloadData];


    展开全文
  • MySQL安装与配置

    2019-08-01 01:49:26
    由于MySQL的官网5.6.42版本的没有MacOS系统的安装文件,所以在终端使用命令行操作下载.下面将命令行窗口的操作以及配置过程的代码留个笔记,以供需要的小伙伴查询. Last login: Wed Jan 2 17:02:31 on ttys000 ...

    由于MySQL的官网5.6.42版本的没有MacOS系统的安装文件,所以在终端使用命令行操作下载.下面将命令行窗口的操作以及配置过程的代码留个笔记,以供需要的小伙伴查询.

    Last login: Wed Jan  2 17:02:31 on ttys000
    liangyufengdeMacBook-Pro:~ liangyufeng$ brew
    Example usage:
      brew search [TEXT|/REGEX/]
      brew info [FORMULA...]
      brew install FORMULA...
      brew update
      brew upgrade [FORMULA...]
      brew uninstall FORMULA...
      brew list [FORMULA...]
    
    Troubleshooting:
      brew config
      brew doctor
      brew install --verbose --debug FORMULA
    
    Contributing:
      brew create [URL [--no-fetch]]
      brew edit [FORMULA...]
    
    Further help:
      brew commands
      brew help [COMMAND]
      man brew
      https://docs.brew.sh
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ brew tap homebrew/versions
    ==> Installing dependencies for git: gettext, pcre2
    ==> Installing git dependency: gettext
    ==> Downloading https://homebrew.bintray.com/bottles/gettext-0.19.8.1.mojave.bot
    Updating Homebrew...
    #######################################################                   76.6%^C
    Error: Git must be installed and in your PATH!
    Error: homebrew/versions was deprecated. This tap is now empty as all its formulae were migrated.
    liangyufengdeMacBook-Pro:~ liangyufeng$ brew info mysql
    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
    mysql: stable 8.0.12 (bottled)
    Open source relational database management system
    https://dev.mysql.com/doc/refman/8.0/en/
    Conflicts with:
      mariadb (because mysql, mariadb, and percona install the same binaries.)
      mariadb-connector-c (because both install plugins)
      mysql-cluster (because mysql, mariadb, and percona install the same binaries.)
      mysql-connector-c (because both install MySQL client libraries)
      percona-server (because mysql, mariadb, and percona install the same binaries.)
    Not installed
    From: /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/mysql.rb
    ==> Dependencies
    Build: cmake ✘
    Required: openssl ✔
    ==> Requirements
    Required: macOS >= 10.10 ✔
    ==> Options
    --with-embedded
    	Build the embedded server
    --with-local-infile
    	Build with local infile loading support
    --with-memcached
    	Build with InnoDB Memcached plugin
    ==> Caveats
    We've installed your MySQL database without a root password. To secure it run:
        mysql_secure_installation
    
    MySQL is configured to only allow connections from localhost by default
    
    To connect run:
        mysql -uroot
    
    To have launchd start mysql now and restart at login:
      brew services start mysql
    Or, if you don't want/need a background service you can just run:
      mysql.server start
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ clear
    
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ brew info mysql
    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
    mysql: stable 8.0.12 (bottled)
    Open source relational database management system
    https://dev.mysql.com/doc/refman/8.0/en/
    Conflicts with:
      mariadb (because mysql, mariadb, and percona install the same binaries.)
      mariadb-connector-c (because both install plugins)
      mysql-cluster (because mysql, mariadb, and percona install the same binaries.)
      mysql-connector-c (because both install MySQL client libraries)
      percona-server (because mysql, mariadb, and percona install the same binaries.)
    Not installed
    From: /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/mysql.rb
    ==> Dependencies
    Build: cmake ✘
    Required: openssl ✔
    ==> Requirements
    Required: macOS >= 10.10 ✔
    ==> Options
    --with-embedded
    	Build the embedded server
    --with-local-infile
    	Build with local infile loading support
    --with-memcached
    	Build with InnoDB Memcached plugin
    ==> Caveats
    We've installed your MySQL database without a root password. To secure it run:
        mysql_secure_installation
    
    MySQL is configured to only allow connections from localhost by default
    
    To connect run:
        mysql -uroot
    
    To have launchd start mysql now and restart at login:
      brew services start mysql
    Or, if you don't want/need a background service you can just run:
      mysql.server start
    ==> Analytics
    install: 63,161 (30d), 183,957 (90d), 888,341 (365d)
    install_on_request: 57,982 (30d), 172,668 (90d), 790,136 (365d)
    build_error: 0 (30d)
    liangyufengdeMacBook-Pro:~ liangyufeng$ mysql
    -bash: mysql: command not found
    liangyufengdeMacBook-Pro:~ liangyufeng$ brew install mysql
    ==> Installing dependencies for git: gettext, pcre2
    ==> Installing git dependency: gettext
    ==> Downloading https://homebrew.bintray.com/bottles/gettext-0.19.8.1.mojave.bottle.tar.gz
    Updating Homebrew...
    ############                                                              17.8%^C
    Error: Git must be installed and in your PATH!
    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
    ==> Downloading https://homebrew.bintray.com/bottles/mysql-8.0.12.mojave.bottle.tar.gz
    ^C
    liangyufengdeMacBook-Pro:~ liangyufeng$ brew install mysql5.6
    ==> Installing dependencies for git: gettext, pcre2
    ==> Installing git dependency: gettext
    ==> Downloading https://homebrew.bintray.com/bottles/gettext-0.19.8.1.mojave.bottle.tar.gz
    Updating Homebrew...
    ######################################################################## 100.0%
    ==> Pouring gettext-0.19.8.1.mojave.bottle.tar.gz
    ==> Caveats
    gettext is keg-only, which means it was not symlinked into /usr/local,
    because macOS provides the BSD gettext library & some software gets confused if both are in the library path.
    
    If you need to have gettext first in your PATH run:
      echo 'export PATH="/usr/local/opt/gettext/bin:$PATH"' >> ~/.bash_profile
    
    For compilers to find gettext you may need to set:
      export LDFLAGS="-L/usr/local/opt/gettext/lib"
      export CPPFLAGS="-I/usr/local/opt/gettext/include"
    
    ==> Summary
    ?  /usr/local/Cellar/gettext/0.19.8.1: 1,935 files, 16.9MB
    ==> Installing git dependency: pcre2
    ==> Downloading https://homebrew.bintray.com/bottles/pcre2-10.32.mojave.bottle.tar.gz
    ######################################################################## 100.0%
    ==> Pouring pcre2-10.32.mojave.bottle.tar.gz
    ?  /usr/local/Cellar/pcre2/10.32: 224 files, 5.5MB
    ==> Installing git
    ==> Downloading https://homebrew.bintray.com/bottles/git-2.19.1.mojave.bottle.tar.gz
    ######################################################################## 100.0%
    ==> Pouring git-2.19.1.mojave.bottle.tar.gz
    ==> Caveats
    Bash completion has been installed to:
      /usr/local/etc/bash_completion.d
    
    zsh completions and functions have been installed to:
      /usr/local/share/zsh/site-functions
    
    Emacs Lisp files have been installed to:
      /usr/local/share/emacs/site-lisp/git
    ==> Summary
    ?  /usr/local/Cellar/git/2.19.1: 1,518 files, 40.1MB
    ==> Caveats
    ==> gettext
    gettext is keg-only, which means it was not symlinked into /usr/local,
    because macOS provides the BSD gettext library & some software gets confused if both are in the library path.
    
    If you need to have gettext first in your PATH run:
      echo 'export PATH="/usr/local/opt/gettext/bin:$PATH"' >> ~/.bash_profile
    
    For compilers to find gettext you may need to set:
      export LDFLAGS="-L/usr/local/opt/gettext/lib"
      export CPPFLAGS="-I/usr/local/opt/gettext/include"
    
    ==> git
    Bash completion has been installed to:
      /usr/local/etc/bash_completion.d
    
    zsh completions and functions have been installed to:
      /usr/local/share/zsh/site-functions
    
    Emacs Lisp files have been installed to:
      /usr/local/share/emacs/site-lisp/git
    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
    ==> Auto-updated Homebrew!
    Updated 1 tap (homebrew/core).
    ==> New Formulae
    anycable-go              dav1d                    gitmoji                  jmxterm                  maven@3.5                oxipng                   rke                      sourcedocs
    aom                      dhall                    goreman                  kubeseal                 mesa                     pass-otp                 ruby@2.4                 spice-protocol
    astrometry-net           dnscontrol               healpix                  kubespy                  minica                   pict                     ruby@2.5                 swagger-codegen@2
    atomist-cli              easyengine               hexyl                    libcerf                  moarvm                   postgresql@10            shellz                   switch-lan-play
    azure-storage-cpp        eg-examples              i386-elf-binutils        libgusb                  needle                   qalculate-gtk            ship                     tass64
    c-blosc                  esptool                  i386-elf-gcc             libnova                  node@10                  rakudo                   simple-scan              tealdeer
    cgit                     fluxctl                  i386-elf-gdb             libpulsar                nqp                      rargs                    sloc                     termtosvg
    create-dmg               fx                       inadyn                   libvirt-glib             nu-smv                   react-native-cli         sng                      um
    cryptominisat            gambit-scheme            interactive-rebase-tool  libvmaf                  objfw                    redis@4.0                solr@6.6                 up
    curl-openssl             ghr                      istioctl                 lsd                      opa                      resin-cli                sonobuoy                 websocat
    ==> Updated Formulae
    gdbm ✔                                  docker-machine-parallels                ibex                                    mongo-c-driver                          scipy
    git ✔                                   docker-squash                           icdiff                                  mongo-cxx-driver                        scour
    libpng ✔                                doctl                                   icecream                                mongo-orchestration                     scrcpy
    libtiff ✔                               docutils                                icemon                                  mongodb                                 sdb
    mercurial ✔                             doitlive                                icu4c                                   mongodb@3.4                             sdcc
    openssl ✔                               dosbox-x                                idris                                   mongodb@3.6                             sdl2
    portmidi ✔                              dovecot                                 ike-scan                                mongoose                                sdl2_image
    sphinx-doc ✔                            doxygen                                 imagemagick                             mono                                    sdl2_mixer
    sqlite ✔                                dpkg                                    imagemagick@6                           mosquitto                               sec
    webp ✔                                  druid                                   imageoptim-cli                          mozjpeg                                 selenium-server-standalone
    abcm2ps                                 dscanner                                imageworsener                           mpc                                     serverless
    abyss                                   dub                                     imapfilter                              mpd                                     sfcgal
    ace                                     duc                                     immortal                                mpich                                   shadowsocks-libev
    activemq                                duo_unix                                influxdb                                mplayer                                 shairport-sync
    advancecomp                             duplicity                               innotop                                 mps-youtube                             shc
    advancemame                             dvm                                     inspircd                                mpv                                     shellcheck
    adwaita-icon-theme                      dwdiff                                  instead                                 mruby                                   shellshare
    agda                                    dwm                                     internetarchive                         mu                                      shfmt
    aha                                     dynare                                  ioping                                  muparser                                shibboleth-sp
    aircrack-ng                             e2fsprogs                               ios-deploy                              mupdf                                   shocco
    akamai                                  eccodes                                 ios-webkit-debug-proxy                  mupdf-tools                             shogun
    alexjs                                  ed                                      ipfs                                    mutt                                    signify-osx
    algernon                                editorconfig                            iproute2mac                             mycli                                   sile
    allure                                  efl                                     ipython                                 mysql                                   simple-amqp-client
    alluxio                                 eigen                                   isync                                   mysql@5.5                               sip
    amazon-ecs-cli                          ejabberd                                itstool                                 mysql@5.6                               siril
    ammonite-repl                           elasticsearch                           jabba                                   mysql@5.7                               skaffold
    amqp-cpp                                elasticsearch@5.6                       jansson                                 mysqltuner                              skafos
    angle-grinder                           elektra                                 jbake                                   n                                       skinny
    angular-cli                             elixir                                  jbig2dec                                nailgun                                 skopeo
    anjuta                                  emacs-clang-complete-async              jboss-forge                             nano                                    sleuthkit
    annie                                   embulk                                  jdnssec-tools                           nanomsg                                 smartmontools
    ansible                                 emscripten                              jdupes                                  nasm                                    smimesign
    ansible-cmdb                            envconsul                               jena                                    nativefier                              snapcraft
    ansifilter                              eprover                                 jenkins                                 nats-streaming-server                   snappystream
    antlr                                   epubcheck                               jenkins-job-builder                     ncmpcpp                                 snapraid
    antlr4-cpp-runtime                      eralchemy                               jenkins-lts                             nco                                     sngrep
    antlr@2                                 erlang                                  jetty                                   ncview                                  softhsm
    apache-arrow                            erlang@17                               jflex                                   ne                                      solr
    apache-arrow-glib                       erlang@18                               jfrog-cli-go                            neo4j                                   sonar-scanner
    apache-drill                            erlang@19                               jhipster                                neofetch                                sonarqube
    apache-flink                            erlang@20                               jid                                     neovim                                  sops
    apache-geode                            eslint                                  joplin                                  netcdf                                  source-highlight
    apache-spark                            etcd                                    jq                                      netdata                                 source-to-image
    app-engine-java                         ethereum                                jrnl                                    netpbm                                  sourcekitten
    aptly                                   euler-py                                json-fortran                            nettle                                  sox
    arangodb                                evince                                  jsonnet                                 newsboat                                spades
    arcade-learning-environment             exercism                                jsonrpc-glib                            nexus                                   spdlog
    ark                                     exiv2                                   juju                                    nghttp2                                 spotbugs
    armadillo                               exploitdb                               jump                                    nginx                                   sqlcipher
    armor                                   eye-d3                                  just                                    ngspice                                 sqldiff
    arx                                     faas-cli                                kafka                                   nifi                                    sqlite-analyzer
    asciidoc                                fabio                                   kakoune                                 nmh                                     sqlmap
    asciidoctor                             fabric                                  kallisto                                nng                                     sqlparse
    asdf                                    fatsort                                 kapacitor                               nnn                                     sratoolkit
    aspectj                                 fauna-shell                             khal                                    node                                    ssh-copy-id
    atdtool                                 fb-client                               kibana                                  node-build                              sshconfigfs
    aubio                                   fbi-servefiles                          kibana@5.6                              node@6                                  sshuttle
    augustus                                fd                                      kitchen-sync                            node@8                                  sslmate
    autopep8                                fdk-aac                                 knot                                    nodeenv                                 sslscan
    autorest                                fdk-aac-encoder                         knot-resolver                           nodenv                                  statik
    aws-es-proxy                            feedgnuplot                             kobalt                                  nsd                                     stellar-core
    aws-sdk-cpp                             feh                                     kompose                                 nss                                     stern
    awscli                                  ffmpeg                                  konoha                                  numpy                                   stgit
    awslogs                                 ffmpeg2theora                           kontena                                 nuxeo                                   stockfish
    azure-cli                               ffmpeg@2.8                              kops                                    nvm                                     stone-soup
    b2-tools                                ffmpegthumbnailer                       kotlin                                  nwchem                                  stormpath-cli
    babel                                   ffms2                                   krakend                                 nyx                                     stormssh
    babl                                    field3d                                 krb5                                    ocaml                                   streamlink
    ballerina                               file-formula                            kube-aws                                ocaml-num                               stubby
    basex                                   fio                                     kubectx                                 ocamlbuild                              stunnel
    bash                                    firebase-cli                            kubeless                                ocamlsdl                                subversion
    bash-snippets                           fish                                    kubernetes-cli                          ocrmypdf                                sundials
    bat                                     flake8                                  kubernetes-helm                         octave                                  supervisor
    bazel                                   flann                                   kubernetes-service-catalog-client       odpi                                    suricata
    bcal                                    fltk                                    kustomize                               ompl                                    svtplay-dl
    bde                                     fluent-bit                              lablgtk                                 oniguruma                               swagger-codegen
    bdw-gc                                  fluid-synth                             landscaper                              opam                                    swi-prolog
    beagle                                  flume                                   languagetool                            open-mpi                                swift
    beast                                   flyway                                  lasso                                   open-scene-graph                        swift-protobuf
    bento4                                  fmpp                                    lastpass-cli                            openapi-generator                       swiftformat
    bettercap                               fmt                                     laszip                                  openblas                                swiftlint
    bgpdump                                 fn                                      latex2html                              opencascade                             swimat
    bgpq3                                   fobis                                   latexdiff                               opencoarrays                            sync_gateway
    bigloo                                  folly                                   lcm                                     openconnect                             syncthing
    binaryen                                fonttools                               ldc                                     opencv                                  sysbench
    bind                                    ford                                    lean-cli                                opencv@2                                sysdig
    binutils                                fork-cleaner                            ledger                                  openfortivpn                            tarantool
    binwalk                                 fping                                   legit                                   openimageio                             tarsnapper
    bison                                   fq                                      lego                                    openldap                                taskell
    bitcoin                                 freeciv                                 leiningen                               openmsx                                 tbb
    bitrise                                 freeling                                leptonica                               openrct2                                tcc
    bitwarden-cli                           freetds                                 less                                    openrtsp                                tcpdump
    blackbox                                freetds@0.91                            lgogdownloader                          openshift-cli                           tcpreplay
    blast                                   frugal                                  libassuan                               openssh                                 tectonic
    blink1                                  fruit                                   libatomic_ops                           openssl@1.1                             telegraf
    bluepill                                fselect                                 libav                                   opentsdb                                teleport
    blueutil                                fswatch                                 libbi                                   openvdb                                 temporal_tables
    bmake                                   fuseki                                  libbitcoin                              opus                                    tepl
    bnd                                     futhark                                 libbitcoin-blockchain                   opus-tools                              termius
    boost                                   fwup                                    libbitcoin-client                       opusfile                                termrec
    boost-bcp                               gammaray                                libbitcoin-database                     orc-tools                               terraform
    boost-build                             gandi.cli                               libbitcoin-explorer                     osm2pgrouting                           terraform-docs
    boost-mpi                               gauche                                  libbitcoin-network                      osmium-tool                             terraform_landscape
    boost-python                            gauge                                   libbitcoin-node                         osquery                                 terragrunt
    boost-python3                           gcab                                    libbitcoin-protocol                     osrm-backend                            tesseract
    botan                                   gcc@6                                   libbitcoin-server                       oysttyer                                testssl
    bowtie2                                 gcc@7                                   libbladerf                              pacapt                                  tgui
    braid                                   gdal                                    libbtbb                                 packer                                  thefuck
    brew-php-switcher                       gdb                                     libccd                                  pagmo                                   theharvester
    brogue                                  gdcm                                    libcdr                                  paket                                   thors-serializer
    brotli                                  gecode                                  libcds                                  pandoc                                  tika
    btfs                                    gedit                                   libcec                                  pandoc-citeproc                         tile38
    buildifier                              geeqie                                  libcouchbase                            pandoc-crossref                         tinc
    buku                                    gegl                                    libdazzle                               pangomm                                 tinyproxy
    bullet                                  genometools                             libdill                                 parallel                                tinyxml2
    bundletool                              geos                                    libedit                                 parallelstl                             tippecanoe
    bup                                     get_iplayer                             liberasurecode                          passenger                               tmux
    byteman                                 getdns                                  libetpan                                passpie                                 tmuxinator-completion
    bzt                                     gexiv2                                  libextractor                            payara                                  tomcat
    c-ares                                  gflags                                  libfabric                               pazpar2                                 tomcat-native
    c10t                                    ghc                                     libfreehand                             pcl                                     tomcat@7
    cabal-install                           ghostscript                             libgcrypt                               pdal                                    tomcat@8
    cabextract                              gimme                                   libgda                                  pdfpc                                   tomee-webprofile
    caddy                                   git-annex                               libgit2                                 pdftoedn                                topgrade
    caf                                     git-archive-all                         libgit2-glib                            pdftoipe                                tor
    caffe                                   git-cinnabar                            libgosu                                 percol                                  tox
    cairo                                   git-lfs                                 libgpg-error                            percona-server                          traefik
    cake                                    git-open                                libgphoto2                              percona-server@5.6                      translate-shell
    calc                                    git-quick-stats                         libgsf                                  percona-toolkit                         translate-toolkit
    camlp5                                  git-recent                              libgxps                                 perl                                    trash-cli
    capstone                                git-review                              libhttpserver                           petsc                                   travis
    cargo-completion                        git-standup                             libical                                 petsc-complex                           tree
    carla                                   git-subrepo                             libidn2                                 pgbadger                                treefrog
    carthage                                gitbucket                               libimagequant                           pgcli                                   tty-solitaire
    cassandra                               gitfs                                   libjson-rpc-cpp                         pgformatter                             ttyd
    catimg                                  gitg                                    libjwt                                  pgroonga                                tundra
    cayley                                  github-markdown-toc                     liblcf                                  pgrouting                               tunnel
    ccache                                  gitlab-gem                              liblo                                   pgweb                                   tup
    ccextractor                             gitlab-runner                           libmagic                                phoronix-test-suite                     tvnamer
    cclive                                  gitless                                 libmatio                                php                                     twarc
    ccm                                     gitversion                              libmicrohttpd                           php-code-sniffer                        twine-pypi
    ceres-solver                            gjs                                     libmspub                                php-cs-fixer                            twoping
    cern-ndiff                              glances                                 libmxml                                 php@7.1                                 typescript
    certbot                                 glib                                    libnice                                 phpmyadmin                              ubertooth
    certigo                                 glibmm                                  libomp                                  phpunit                                 ucloud
    cfitsio                                 glm                                     libopendkim                             picard-tools                            uhd
    cglm                                    global                                  libopusenc                              picat                                   unbound
    chakra                                  globjects                               libosmium                               pig                                     uncrustify
    chamber                                 glslang                                 libphonenumber                          pijul                                   unnethack
    cheat                                   gmic                                    libplctag                               pike                                    unoconv
    checkbashisms                           gmime                                   libplist                                pilosa                                  unshield
    checkstyle                              gmsh                                    libpq                                   pip-completion                          upscaledb
    chicken                                 gmt                                     libpqxx                                 pipenv                                  urdfdom_headers
    chisel                                  gmt@4                                   libproxy                                pius                                    urh
    choose                                  gnome-latex                             libpsl                                  pixman                                  uriparser
    chrome-export                           gnu-sed                                 libpst                                  pktanon                                 uru
    chronograf                              gnu-tar                                 libqalculate                            planck                                  urweb
    chruby-fish                             gnu-units                               librdkafka                              plantuml                                v8
    circleci                                gnupg                                   librealsense                            platformio                              vagrant-completion
    citus                                   gnuplot                                 libressl                                plplot                                  vala
    ckan                                    gnuradio                                librsvg                                 pmd                                     valgrind
    clamav                                  gnutls                                  libsamplerate                           pngquant                                vapoursynth
    clang-format                            go                                      libsass                                 podofo                                  varnish
    clblast                                 go-bindata                              libsecret                               ponyc                                   vault
    cli53                                   go-statik                               libsigc++                               poppler                                 vaulted
    cling                                   go@1.10                                 libsodium                               posh                                    vegeta
    clojure                                 goaccess                                libsoup                                 postgis                                 verilator
    clojurescript                           gobject-introspection                   libspectre                              postgresql                              vert.x
    closure-compiler                        gocryptfs                               libssh                                  ppsspp                                  vfuse
    cmake                                   godep                                   libstfl                                 pqiv                                    vice
    cmark-gfm                               goenv                                   libswiften                              pre-commit                              vim
    cmdshelf                                goffice                                 libtcod                                 presto                                  vim@7.4
    cnats                                   golang-migrate                          libtensorflow                           prettier                                vips
    cockroach                               googler                                 libtins                                 primesieve                              visp
    cocoapods                               goolabs                                 libtorrent-rasterbar                    prips                                   vnu
    codemod                                 gopass                                  libuv                                   prometheus                              voldemort
    cointop                                 goreleaser                              libvirt                                 proselint                               vsts-cli
    collectd                                gosu                                    libvisio                                protobuf                                vte3
    collector-sidecar                       gowsdl                                  libvoikko                               ps2eps                                  vtk
    commandbox                              gpa                                     libwebsockets                           pspg                                    wabt
    composer                                gpgme                                   libxlsxwriter                           pulumi                                  wakatime-cli
    conan                                   gphoto2                                 libxml2                                 pumba                                   wallpaper
    configen                                gprof2dot                               libxmlsec1                              purescript                              wartremover
    confluent-oss                           gpsbabel                                libxslt                                 pushpin                                 watchman
    console_bridge                          gr-osmosdr                              lighttpd                                pwntools                                watson
    consul                                  gradio                                  linkerd                                 py2cairo                                wcslib
    container-diff                          gradle                                  livestreamer                            py3cairo                                weaver
    convox                                  grafana                                 llvm                                    pyenv                                   weboob
    cookiecutter                            grails                                  llvm@3.9                                pygitup                                 webpack
    coq                                     grakn                                   llvm@4                                  pygobject3                              weechat
    couchdb                                 graph-tool                              llvm@5                                  pyinvoke                                wesnoth
    cp2k                                    graphicsmagick                          llvm@6                                  python                                  wget
    cpanminus                               graphite2                               lmdb                                    python-markdown                         when
    cppcheck                                grep                                    lmod                                    q                                       whois
    cpprestsdk                              grib-api                                logstash                                qbs                                     widelands
    crc32c                                  grip                                    logtalk                                 qcli                                    wine
    credstash                               groff                                   lolcat                                  qemu                                    winetricks
    cromwell                                groovy                                  lsdvd                                   qmmp                                    wireguard-go
    crosstool-ng                            groovysdk                               lumo                                    qpdf                                    wireguard-tools
    crowdin                                 grpc                                    luvit                                   qpid-proton                             wireshark
    cryptopp                                grunt-cli                               lxc                                     qt                                      woboq_codebrowser
    crystal                                 grunt-completion                        lynis                                   quicktype                               wolfssl
    crystal-icr                             grv                                     mackup                                  r                                       wp-cli
    cucumber-cpp                            gst-plugins-good                        macvim                                  rabbitmq                                wp-cli-completion
    curaengine                              gst-plugins-ugly                        magic-wormhole                          radare2                                 wpscan
    curl                                    gst-python                              makensis                                rakudo-star                             wskdeploy
    cvs2svn                                 gstreamermm                             mame                                    rancher-cli                             wtf
    cython                                  gtk+3                                   mandoc                                  range-v3                                wxmaxima
    dartsim                                 gtk-doc                                 mapnik                                  rbspy                                   x264
    dash                                    gtkmm3                                  mapserver                               rclone                                  xcodegen
    dasht                                   gtkspell3                               mariadb                                 rdesktop                                xctool
    dateutils                               gucharmap                               mariadb-connector-c                     re2                                     xmake
    davix                                   gupnp-av                                mariadb@10.0                            rebar3                                  xml-security-c
    dbhash                                  gupnp-tools                             mariadb@10.1                            recon-ng                                xml-tooling-c
    dbus                                    gwyddion                                mariadb@10.2                            recutils                                xmrig
    dcd                                     gzip                                    mas                                     redis                                   xonsh
    dcm2niix                                hadolint                                math-comp                               redo                                    xsimd
    ddgr                                    handbrake                               maven                                   remarshal                               xtensor
    dependency-check                        hapi-fhir-cli                           maxwell                                 repo                                    yaml-cpp
    dfmt                                    haproxy                                 mdcat                                   restic                                  yamllint
    dhall-json                              harfbuzz                                mdp                                     restview                                yank
    dialog                                  hashpump                                mdv                                     riemann-client                          yara
    diamond                                 haskell-stack                           media-info                              rmlint                                  yarn
    diceware                                haste-client                            megacmd                                 robot-framework                         yasm
    diff-pdf                                hbase                                   memcached                               rom-tools                               yaz
    diffoscope                              hcloud                                  meson                                   root                                    ydcv
    diffutils                               hdf5                                    metaproxy                               roswell                                 ykman
    digdag                                  hdf5@1.8                                micronaut                               rpm                                     yle-dl
    digitemp                                hebcal                                  midnight-commander                      rst-lint                                yosys
    direnv                                  helmfile                                mikutter                                rswift                                  you-get
    dita-ot                                 help2man                                mill                                    rtags                                   youtube-dl
    django-completion                       hfstospell                              miller                                  ruby                                    yq
    dlib                                    highlight                               mimic                                   ruby-build                              z3
    dmd                                     hiredis                                 minio                                   ruby@2.3                                zanata-client
    dnscrypt-proxy                          hive                                    minio-mc                                rust                                    zebra
    dnscrypt-wrapper                        hmmer                                   miniserve                               rustup-init                             zeromq
    dnsmasq                                 homebank                                minizinc                                s-search                                zile
    dnstwist                                honcho                                  mint                                    s3cmd                                   zim
    docfx                                   howdoi                                  mitie                                   safe                                    zimg
    docker                                  http-parser                             mkcert                                  sagittarius-scheme                      znc
    docker-completion                       httpd                                   mkclean                                 salt                                    zookeeper
    docker-compose                          httpie                                  mkdocs                                  sbcl                                    zorba
    docker-compose-completion               hub                                     mkl-dnn                                 sbt                                     zsh
    docker-credential-helper-ecr            hugo                                    mkvtoolnix                              sbt@0.13                                zsh-autosuggestions
    docker-ls                               hunspell                                mlt                                     scala                                   zsh-completions
    docker-machine                          hwloc                                   mmseqs2                                 scalaenv                                zstd
    docker-machine-completion               hydra                                   mockserver                              scalapack                               zurl
    docker-machine-driver-xhyve             hyperfine                               monero                                  sceptre
    docker-machine-nfs                      i2pd                                    monetdb                                 schismtracker
    ==> Renamed Formulae
    gtksourceview@4 -> gtksourceview4       gutenberg -> zola                       hh -> hstr                              mat -> mat2                             php72 -> php@7.2
    ==> Deleted Formulae
    apple-gcc42         corebird            gnome-doc-utils     heroku              ld64                mimms               open-vcdiff         pldebugger          reclass             sickbeard
    aptly-completion    datomic             gradle@2.14         ib                  lsh                 nesemu2             opensyobon          pxz                 rock                taylor
    cctools             ffmbc               gv                  juju-quickstart     maven@3.0           nethack4            php@5.6             pyexiv2             ruby@2.2            tcptrack
    cctools-headers     gjstest             hachoir-metadata    kibana@4.4          maven@3.1           onepass             php@7.0             queequeg            sary
    
    Error: HOMEBREW_LOGS was not exported!
    Please don't worry, you likely hit a bug auto-updating from an old version.
    Rerun your command, everything is up-to-date and fine now.
    liangyufengdeMacBook-Pro:~ liangyufeng$ which mysql
    liangyufengdeMacBook-Pro:~ liangyufeng$ mysql
    -bash: mysql: command not found
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ cd /usr/local/Cellar/
    freetype/   gettext/    jpeg/       libogg/     libtiff/    mercurial/  pcre2/      portmidi/   readline/   sdl_image/  sdl_ttf/    sqlite/     
    gdbm/       git/        libmikmod/  libpng/     libvorbis/  openssl/    pkg-config/ python@2/   sdl/        sdl_mixer/  sphinx-doc/ webp/       
    liangyufengdeMacBook-Pro:~ liangyufeng$ cd /usr/local/Cellar/
    liangyufengdeMacBook-Pro:Cellar liangyufeng$ ll
    -bash: ll: command not found
    liangyufengdeMacBook-Pro:Cellar liangyufeng$ ls
    freetype	gettext		jpeg		libogg		libtiff		mercurial	pcre2		portmidi	readline	sdl_image	sdl_ttf		sqlite
    gdbm		git		libmikmod	libpng		libvorbis	openssl		pkg-config	python@2	sdl		sdl_mixer	sphinx-doc	webp
    liangyufengdeMacBook-Pro:Cellar liangyufeng$ ls -lrt
    total 0
    drwxr-xr-x  3 liangyufeng  staff  96 10  9 00:13 gdbm
    drwxr-xr-x  3 liangyufeng  staff  96 10  9 00:13 openssl
    drwxr-xr-x  3 liangyufeng  staff  96 10  9 00:14 readline
    drwxr-xr-x  3 liangyufeng  staff  96 10  9 00:14 sqlite
    drwxr-xr-x  3 liangyufeng  staff  96 10  9 00:21 pkg-config
    drwxr-xr-x  3 liangyufeng  staff  96 10  9 00:21 sphinx-doc
    drwxr-xr-x  3 liangyufeng  admin  96 10  9 00:22 python@2
    drwxr-xr-x  3 liangyufeng  staff  96 10  9 00:28 mercurial
    drwxr-xr-x  3 liangyufeng  staff  96 10  9 00:28 sdl
    drwxr-xr-x  3 liangyufeng  staff  96 10  9 00:28 jpeg
    drwxr-xr-x  3 liangyufeng  staff  96 10  9 00:28 libpng
    drwxr-xr-x  3 liangyufeng  staff  96 10  9 00:28 libtiff
    drwxr-xr-x  3 liangyufeng  staff  96 10  9 00:28 webp
    drwxr-xr-x  3 liangyufeng  staff  96 10  9 00:28 sdl_image
    drwxr-xr-x  3 liangyufeng  staff  96 10  9 00:29 freetype
    drwxr-xr-x  3 liangyufeng  staff  96 10  9 00:29 sdl_ttf
    drwxr-xr-x  3 liangyufeng  staff  96 10  9 00:32 libmikmod
    drwxr-xr-x  3 liangyufeng  staff  96 10  9 00:32 libogg
    drwxr-xr-x  3 liangyufeng  staff  96 10  9 00:32 libvorbis
    drwxr-xr-x  3 liangyufeng  staff  96 10  9 00:32 sdl_mixer
    drwxr-xr-x  3 liangyufeng  staff  96 10  9 00:32 portmidi
    drwxr-xr-x  3 liangyufeng  staff  96  1 11 20:06 gettext
    drwxr-xr-x  3 liangyufeng  staff  96  1 11 20:06 pcre2
    drwxr-xr-x  3 liangyufeng  staff  96  1 11 20:08 git
    liangyufengdeMacBook-Pro:Cellar liangyufeng$ brew install mysql@5.6.42
    Error: No available formula with the name "mysql@5.6.42" 
    ==> Searching for a previously deleted formula (in the last month)...
    Warning: homebrew/core is shallow clone. To get complete history run:
      git -C "$(brew --repo homebrew/core)" fetch --unshallow
    
    Error: No previously deleted formula found.
    ==> Searching for similarly named formulae...
    Error: No similarly named formulae found.
    ==> Searching taps...
    ==> Searching taps on GitHub...
    Error: No formulae found in taps.
    liangyufengdeMacBook-Pro:Cellar liangyufeng$ brew install mysql@5.6
    ==> Installing dependencies for mysql@5.6: openssl
    ==> Installing mysql@5.6 dependency: openssl
    ==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2q.mojave.bottle.tar.gz
    ######################################################################## 100.0%
    ==> Pouring openssl-1.0.2q.mojave.bottle.tar.gz
    ==> Caveats
    A CA file has been bootstrapped using certificates from the SystemRoots
    keychain. To add additional certificates (e.g. the certificates added in
    the System keychain), place .pem files in
      /usr/local/etc/openssl/certs
    
    and run
      /usr/local/opt/openssl/bin/c_rehash
    
    openssl is keg-only, which means it was not symlinked into /usr/local,
    because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.
    
    If you need to have openssl first in your PATH run:
      echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
    
    For compilers to find openssl you may need to set:
      export LDFLAGS="-L/usr/local/opt/openssl/lib"
      export CPPFLAGS="-I/usr/local/opt/openssl/include"
    
    For pkg-config to find openssl you may need to set:
      export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"
    
    ==> Summary
    ?  /usr/local/Cellar/openssl/1.0.2q: 1,794 files, 12.1MB
    ==> Installing mysql@5.6
    ==> Downloading https://homebrew.bintray.com/bottles/mysql@5.6-5.6.42.mojave.bottle.1.tar.gz
    ######################################################################## 100.0%
    ==> Pouring mysql@5.6-5.6.42.mojave.bottle.1.tar.gz
    ==> /usr/local/Cellar/mysql@5.6/5.6.42/bin/mysql_install_db --verbose --user=liangyufeng --basedir=/usr/local/Cellar/mysql@5.6/5.6.42 --datadir=/usr/local/var/mysql --tmpdir=/tmp
    ==> Caveats
    A "/etc/my.cnf" from another install may interfere with a Homebrew-built
    server starting up correctly.
    
    MySQL is configured to only allow connections from localhost by default
    
    To connect:
        mysql -uroot
    
    mysql@5.6 is keg-only, which means it was not symlinked into /usr/local,
    because this is an alternate version of another formula.
    
    If you need to have mysql@5.6 first in your PATH run:
      echo 'export PATH="/usr/local/opt/mysql@5.6/bin:$PATH"' >> ~/.bash_profile
    
    For compilers to find mysql@5.6 you may need to set:
      export LDFLAGS="-L/usr/local/opt/mysql@5.6/lib"
      export CPPFLAGS="-I/usr/local/opt/mysql@5.6/include"
    
    
    To have launchd start mysql@5.6 now and restart at login:
      brew services start mysql@5.6
    Or, if you don't want/need a background service you can just run:
      /usr/local/opt/mysql@5.6/bin/mysql.server start
    ==> Summary
    ?  /usr/local/Cellar/mysql@5.6/5.6.42: 342 files, 154.2MB
    ==> Caveats
    ==> openssl
    A CA file has been bootstrapped using certificates from the SystemRoots
    keychain. To add additional certificates (e.g. the certificates added in
    the System keychain), place .pem files in
      /usr/local/etc/openssl/certs
    
    and run
      /usr/local/opt/openssl/bin/c_rehash
    
    openssl is keg-only, which means it was not symlinked into /usr/local,
    because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.
    
    If you need to have openssl first in your PATH run:
      echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
    
    For compilers to find openssl you may need to set:
      export LDFLAGS="-L/usr/local/opt/openssl/lib"
      export CPPFLAGS="-I/usr/local/opt/openssl/include"
    
    For pkg-config to find openssl you may need to set:
      export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"
    
    ==> mysql@5.6
    A "/etc/my.cnf" from another install may interfere with a Homebrew-built
    server starting up correctly.
    
    MySQL is configured to only allow connections from localhost by default
    
    To connect:
        mysql -uroot
    
    mysql@5.6 is keg-only, which means it was not symlinked into /usr/local,
    because this is an alternate version of another formula.
    
    If you need to have mysql@5.6 first in your PATH run:
      echo 'export PATH="/usr/local/opt/mysql@5.6/bin:$PATH"' >> ~/.bash_profile
    
    For compilers to find mysql@5.6 you may need to set:
      export LDFLAGS="-L/usr/local/opt/mysql@5.6/lib"
      export CPPFLAGS="-I/usr/local/opt/mysql@5.6/include"
    
    
    To have launchd start mysql@5.6 now and restart at login:
      brew services start mysql@5.6
    Or, if you don't want/need a background service you can just run:
      /usr/local/opt/mysql@5.6/bin/mysql.server start
    liangyufengdeMacBook-Pro:Cellar liangyufeng$ mysql -uroot
    -bash: mysql: command not found
    liangyufengdeMacBook-Pro:Cellar liangyufeng$ /usr/local/Cellar/m
    mercurial/ mysql@5.6/ 
    liangyufengdeMacBook-Pro:Cellar liangyufeng$ /usr/local/Cellar/m
    mercurial/ mysql@5.6/ 
    liangyufengdeMacBook-Pro:Cellar liangyufeng$ /usr/local/Cellar/mysql\@5.6/5.6.42/
    .bottle/       .brew/         bin/           include/       lib/           libexec/       scripts/       share/         sql-bench/     support-files/ 
    liangyufengdeMacBook-Pro:Cellar liangyufeng$ /usr/local/Cellar/mysql\@5.6/5.6.42/bin/msql2mysql 
    freetype/   gettext/    jpeg/       libogg/     libtiff/    mercurial/  openssl/    pkg-config/ python@2/   sdl/        sdl_mixer/  sphinx-doc/ webp/       
    gdbm/       git/        libmikmod/  libpng/     libvorbis/  mysql@5.6/  pcre2/      portmidi/   readline/   sdl_image/  sdl_ttf/    sqlite/     
    liangyufengdeMacBook-Pro:Cellar liangyufeng$ /usr/local/Cellar/mysql\@5.6/5.6.42/bin/msql2mysql 
    Warning: /usr/local/Cellar/mysql@5.6/5.6.42/bin/msql2mysql is deprecated and will be removed in a future version.
    
    ^C
    liangyufengdeMacBook-Pro:Cellar liangyufeng$ cd /usr/local/Cellar/mysql\@5.6/5.6.42/bin/
    liangyufengdeMacBook-Pro:bin liangyufeng$ ls
    innochecksum			mysql.server			mysql_fix_extensions		mysql_zap			mysqldump			perror
    msql2mysql			mysql_client_test		mysql_install_db		mysqladmin			mysqldumpslow			replace
    my_print_defaults		mysql_client_test_embedded	mysql_plugin			mysqlbinlog			mysqlhotcopy			resolve_stack_dump
    myisam_ftdump			mysql_config			mysql_secure_installation	mysqlbug			mysqlimport			resolveip
    myisamchk			mysql_config_editor		mysql_setpermission		mysqlcheck			mysqlshow
    myisamlog			mysql_convert_table_format	mysql_tzinfo_to_sql		mysqld				mysqlslap
    myisampack			mysql_embedded			mysql_upgrade			mysqld_multi			mysqltest
    mysql				mysql_find_rows			mysql_waitpid			mysqld_safe			mysqltest_embedded
    liangyufengdeMacBook-Pro:bin liangyufeng$ ls -lrt
    total 253368
    -r-xr-xr-x  1 liangyufeng  staff   3157072  9 10 18:23 replace
    -r-xr-xr-x  1 liangyufeng  staff     34938  9 10 18:23 mysqlhotcopy
    -r-xr-xr-x  1 liangyufeng  staff      7424  9 10 18:23 mysqldumpslow
    -r-xr-xr-x  1 liangyufeng  staff      3942  9 10 18:23 mysql_zap
    -r-xr-xr-x  1 liangyufeng  staff     17550  9 10 18:23 mysql_setpermission
    -r-xr-xr-x  1 liangyufeng  staff     10106  9 10 18:23 mysql_secure_installation
    lrwxr-xr-x  1 liangyufeng  staff        27  9 10 18:23 mysql_install_db -> ../scripts/mysql_install_db
    -r-xr-xr-x  1 liangyufeng  staff      1331  9 10 18:23 mysql_fix_extensions
    -r-xr-xr-x  1 liangyufeng  staff      3374  9 10 18:23 mysql_find_rows
    -r-xr-xr-x  1 liangyufeng  staff      4299  9 10 18:23 mysql_convert_table_format
    lrwxr-xr-x  1 liangyufeng  staff        29  9 10 18:23 mysql.server -> ../support-files/mysql.server
    -r-xr-xr-x  1 liangyufeng  staff   3402280  9 10 18:23 myisamlog
    -r-xr-xr-x  1 liangyufeng  staff   3185296  1 11 20:21 innochecksum
    -r-xr-xr-x  1 liangyufeng  staff   3180344  1 11 20:21 my_print_defaults
    -r-xr-xr-x  1 liangyufeng  staff   3425124  1 11 20:21 myisam_ftdump
    -r-xr-xr-x  1 liangyufeng  staff   3519928  1 11 20:21 myisamchk
    -r-xr-xr-x  1 liangyufeng  staff   3443204  1 11 20:21 myisampack
    -r-xr-xr-x  1 liangyufeng  staff   3470344  1 11 20:21 mysql
    -r-xr-xr-x  1 liangyufeng  staff   3761480  1 11 20:21 mysql_client_test
    -r-xr-xr-x  1 liangyufeng  staff  11384760  1 11 20:21 mysql_client_test_embedded
    -r-xr-xr-x  1 liangyufeng  staff   3374832  1 11 20:21 mysql_config_editor
    -r-xr-xr-x  1 liangyufeng  staff  11080428  1 11 20:21 mysql_embedded
    -r-xr-xr-x  1 liangyufeng  staff   3189504  1 11 20:21 mysql_plugin
    -r-xr-xr-x  1 liangyufeng  staff   3147136  1 11 20:21 mysql_tzinfo_to_sql
    -r-xr-xr-x  1 liangyufeng  staff   3484512  1 11 20:21 mysql_upgrade
    -r-xr-xr-x  1 liangyufeng  staff   3180128  1 11 20:21 mysql_waitpid
    -r-xr-xr-x  1 liangyufeng  staff   3378320  1 11 20:21 mysqladmin
    -r-xr-xr-x  1 liangyufeng  staff   3547660  1 11 20:21 mysqlbinlog
    -r-xr-xr-x  1 liangyufeng  staff   3373696  1 11 20:21 mysqlcheck
    -r-xr-xr-x  1 liangyufeng  staff  11766608  1 11 20:21 mysqld
    -r-xr-xr-x  1 liangyufeng  staff   3435992  1 11 20:21 mysqldump
    -r-xr-xr-x  1 liangyufeng  staff   3370296  1 11 20:21 mysqlimport
    -r-xr-xr-x  1 liangyufeng  staff   3368808  1 11 20:21 mysqlshow
    -r-xr-xr-x  1 liangyufeng  staff   3385220  1 11 20:21 mysqlslap
    -r-xr-xr-x  1 liangyufeng  staff   3618408  1 11 20:21 mysqltest
    -r-xr-xr-x  1 liangyufeng  staff  11203720  1 11 20:21 mysqltest_embedded
    -r-xr-xr-x  1 liangyufeng  staff   3284632  1 11 20:21 perror
    -r-xr-xr-x  1 liangyufeng  staff   3187036  1 11 20:21 resolve_stack_dump
    -r-xr-xr-x  1 liangyufeng  staff   3180348  1 11 20:21 resolveip
    -r-xr-xr-x  1 liangyufeng  staff      1569  1 11 20:21 msql2mysql
    -r-xr-xr-x  1 liangyufeng  staff      6556  1 11 20:21 mysql_config
    -r-xr-xr-x  1 liangyufeng  staff     10928  1 11 20:21 mysqlbug
    -r-xr-xr-x  1 liangyufeng  staff     27015  1 11 20:21 mysqld_multi
    -r-xr-xr-x  1 liangyufeng  staff     27430  1 11 20:21 mysqld_safe
    liangyufengdeMacBook-Pro:bin liangyufeng$ mysqld
    -bash: mysqld: command not found
    liangyufengdeMacBook-Pro:bin liangyufeng$ ./mysql
    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
    liangyufengdeMacBook-Pro:bin liangyufeng$ ./mysqld
    2019-01-11 20:23:15 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
    2019-01-11 20:23:15 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
    2019-01-11 20:23:15 0 [Note] ./mysqld (mysqld 5.6.42) starting as process 62433 ...
    2019-01-11 20:23:15 62433 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
    2019-01-11 20:23:15 62433 [Note] Plugin 'FEDERATED' is disabled.
    2019-01-11 20:23:15 62433 [Note] InnoDB: Using atomics to ref count buffer pool pages
    2019-01-11 20:23:15 62433 [Note] InnoDB: The InnoDB memory heap is disabled
    2019-01-11 20:23:15 62433 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
    2019-01-11 20:23:15 62433 [Note] InnoDB: Memory barrier is not used
    2019-01-11 20:23:15 62433 [Note] InnoDB: Compressed tables use zlib 1.2.11
    2019-01-11 20:23:15 62433 [Note] InnoDB: Using CPU crc32 instructions
    2019-01-11 20:23:15 62433 [Note] InnoDB: Initializing buffer pool, size = 128.0M
    2019-01-11 20:23:15 62433 [Note] InnoDB: Completed initialization of buffer pool
    2019-01-11 20:23:15 62433 [Note] InnoDB: Highest supported file format is Barracuda.
    2019-01-11 20:23:15 62433 [Note] InnoDB: 128 rollback segment(s) are active.
    2019-01-11 20:23:15 62433 [Note] InnoDB: Waiting for purge to start
    2019-01-11 20:23:15 62433 [Note] InnoDB: 5.6.42 started; log sequence number 1625987
    2019-01-11 20:23:15 62433 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: ab6bd996-159b-11e9-afc2-98bff386c64c.
    2019-01-11 20:23:15 62433 [Note] RSA private key file not found: /usr/local/var/mysql//private_key.pem. Some authentication plugins will not work.
    2019-01-11 20:23:15 62433 [Note] RSA public key file not found: /usr/local/var/mysql//public_key.pem. Some authentication plugins will not work.
    2019-01-11 20:23:15 62433 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
    2019-01-11 20:23:15 62433 [Note]   - '127.0.0.1' resolves to '127.0.0.1';
    2019-01-11 20:23:15 62433 [Note] Server socket created on IP: '127.0.0.1'.
    2019-01-11 20:23:15 62433 [Note] Event Scheduler: Loaded 0 events
    2019-01-11 20:23:15 62433 [Note] ./mysqld: ready for connections.
    Version: '5.6.42'  socket: '/tmp/mysql.sock'  port: 3306  Homebrew
    ^C
    ^C^C^C
    
    
    
    
    ^C^C^C^C^C
    ^C^C^C^CKilled: 9
    liangyufengdeMacBook-Pro:bin liangyufeng$ 
    liangyufengdeMacBook-Pro:bin liangyufeng$ 
    liangyufengdeMacBook-Pro:bin liangyufeng$ 
    liangyufengdeMacBook-Pro:bin liangyufeng$ which mysqld
    liangyufengdeMacBook-Pro:bin liangyufeng$ source ~/.bash_profile 
    liangyufengdeMacBook-Pro:bin liangyufeng$ which mysqld
    /usr/local/opt/mysql@5.6/bin/mysqld
    liangyufengdeMacBook-Pro:bin liangyufeng$ cd
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ ll
    -bash: ll: command not found
    liangyufengdeMacBook-Pro:~ liangyufeng$ ls
    Applications			Downloads			Movies				Public				Virtual Machines.localized	iCloud Drive(归档)
    Desktop				Kingsoft			Music				PycharmProjects			VirtualBox VMs			test
    Documents			Library				Pictures			VMware				day33上课便签.txt		venv
    liangyufengdeMacBook-Pro:~ liangyufeng$ nohup mysqld &
    [1] 62603
    liangyufengdeMacBook-Pro:~ liangyufeng$ appending output to nohup.out
    
    liangyufengdeMacBook-Pro:~ liangyufeng$ ps -ef|grep mysqld
      501 62603 25300   0  9:16下午 ttys000    0:00.47 mysqld
      501 62605 25300   0  9:17下午 ttys000    0:00.00 grep mysqld
    liangyufengdeMacBook-Pro:~ liangyufeng$ ps -ef|grep mysqld
      501 62603 25300   0  9:16下午 ttys000    0:00.47 mysqld
      501 62608 25300   0  9:17下午 ttys000    0:00.00 grep mysqld
      501 62606 62055   0  9:17下午 ttys001    0:00.40 mysqld
    liangyufengdeMacBook-Pro:~ liangyufeng$ kill -9 62606
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    

      之后打开的一个终端窗口:

    Last login: Fri Jan 11 20:11:14 on ttys001
    liangyufengdeMacBook-Pro:~ liangyufeng$ brew info mysql
    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
    mysql: stable 8.0.13 (bottled)
    Open source relational database management system
    https://dev.mysql.com/doc/refman/8.0/en/
    Conflicts with:
      mariadb (because mysql, mariadb, and percona install the same binaries.)
      mariadb-connector-c (because both install plugins)
      mysql-cluster (because mysql, mariadb, and percona install the same binaries.)
      mysql-connector-c (because both install MySQL client libraries)
      percona-server (because mysql, mariadb, and percona install the same binaries.)
    Not installed
    From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/mysql.rb
    ==> Dependencies
    Build: cmake ✘
    Required: openssl ✔
    ==> Requirements
    Required: macOS >= 10.10 ✔
    ==> Caveats
    We've installed your MySQL database without a root password. To secure it run:
        mysql_secure_installation
    
    MySQL is configured to only allow connections from localhost by default
    
    To connect run:
        mysql -uroot
    
    To have launchd start mysql now and restart at login:
      brew services start mysql
    Or, if you don't want/need a background service you can just run:
      mysql.server start
    ==> Analytics
    install: 63,161 (30 days), 183,957 (90 days), 888,341 (365 days)
    install_on_request: 57,982 (30 days), 172,668 (90 days), 790,136 (365 days)
    build_error: 0 (30 days)
    liangyufengdeMacBook-Pro:~ liangyufeng$ brew search mysql
    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
    ==> Formulae
    automysqlbackup              mysql++                      mysql-cluster                mysql-connector-c++          mysql-search-replace         mysql@5.5                    mysql@5.7
    mysql                        mysql-client                 mysql-connector-c            mysql-sandbox                mysql-utilities              mysql@5.6                    mysqltuner
    
    ==> Casks
    homebrew/cask/mysql-connector-python    homebrew/cask/mysql-shell               homebrew/cask/mysql-utilities           homebrew/cask/navicat-for-mysql         homebrew/cask/sqlpro-for-mysql
    liangyufengdeMacBook-Pro:~ liangyufeng$ /usr/local/Cellar/
    freetype/   gettext/    jpeg/       libogg/     libtiff/    mercurial/  openssl/    pkg-config/ python@2/   sdl/        sdl_mixer/  sphinx-doc/ webp/       
    gdbm/       git/        libmikmod/  libpng/     libvorbis/  mysql@5.6/  pcre2/      portmidi/   readline/   sdl_image/  sdl_ttf/    sqlite/     
    liangyufengdeMacBook-Pro:~ liangyufeng$ /usr/local/Cellar/mysql\@5.6/5.6.42/bin/mysql
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 1
    Server version: 5.6.42 Homebrew
    
    Copyright (c) 2000, 2018, 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.
    
    mysql> 
    mysql> 
    mysql> 
    mysql> 
    mysql> 
    mysql> 
    mysql> exit
    Bye
    liangyufengdeMacBook-Pro:~ liangyufeng$ /usr/local/Cellar/mysql\@5.6/5.6.42/bin/mysql
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 2
    Server version: 5.6.42 Homebrew
    
    Copyright (c) 2000, 2018, 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.
    
    mysql> exit
    Bye
    liangyufengdeMacBook-Pro:~ liangyufeng$ /usr/local/Cellar/mysql\@5.6/5.6.42/bin/mysql
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 3
    Server version: 5.6.42 Homebrew
    
    Copyright (c) 2000, 2018, 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.
    
    mysql> exit
    Bye
    liangyufengdeMacBook-Pro:~ liangyufeng$ echo "/usr/local/Cellar/mysql\@5.6/5.6.42/bin/mysql" >> ~/.bash_profile 
    liangyufengdeMacBook-Pro:~ liangyufeng$ cat ~/.bash_profile
    
    # Setting PATH for Python 3.6
    # The original version is saved in .bash_profile.pysave
    PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
    export PATH
    /usr/local/Cellar/mysql\@5.6/5.6.42/bin/mysql
    liangyufengdeMacBook-Pro:~ liangyufeng$ vi ~/.bash_profile
    liangyufengdeMacBook-Pro:~ liangyufeng$ source ~/.bash_profile
    liangyufengdeMacBook-Pro:~ liangyufeng$ mysql
    -bash: mysql: command not found
    liangyufengdeMacBook-Pro:~ liangyufeng$ vi ~/.bash_profile
    liangyufengdeMacBook-Pro:~ liangyufeng$ cat ~/.
    ./                   .CFUserTextEncoding  .Trash/              .bash_profile        .config/             .idlerc/             .mysql_history       .sogouinput/         .viminfo
    ../                  .DS_Store            .bash_history        .bash_sessions/      .gitconfig           .kingsoft/           .python_history      .ssh/                .vscode/
    liangyufengdeMacBook-Pro:~ liangyufeng$ echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
    liangyufengdeMacBook-Pro:~ liangyufeng$ pwd
    /Users/liangyufeng
    liangyufengdeMacBook-Pro:~ liangyufeng$ echo 'export PATH="/usr/local/Cellar/mysql\@5.6/5.6.42/bin/mysql:$PATH"' >> ~/.bash_profile
    liangyufengdeMacBook-Pro:~ liangyufeng$ source ~/.bash_profile 
    liangyufengdeMacBook-Pro:~ liangyufeng$ mysql
    -bash: mysql: command not found
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ cat ~/.bash_profile 
    
    # Setting PATH for Python 3.6
    # The original version is saved in .bash_profile.pysave
    PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}":/usr/local/Cellar/mysql\@5.6/5.6.42/bin/mysql
    export PATH
    export PATH="/usr/local/Cellar/mysql\@5.6/5.6.42/bin/mysql:$PATH"
    liangyufengdeMacBook-Pro:~ liangyufeng$ which mysql
    liangyufengdeMacBook-Pro:~ liangyufeng$ vim ~/.bash_profile 
    liangyufengdeMacBook-Pro:~ liangyufeng$ source ~/.bash_profile 
    liangyufengdeMacBook-Pro:~ liangyufeng$ mysql
    -bash: mysql: command not found
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ echo 'export PATH="/usr/local/opt/mysql@5.6/bin:$PATH"' >> ~/.bash_profile
    liangyufengdeMacBook-Pro:~ liangyufeng$ vi ~/.bash_profile
    liangyufengdeMacBook-Pro:~ liangyufeng$ source ~/.bash_profile 
    liangyufengdeMacBook-Pro:~ liangyufeng$ mysql
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 4
    Server version: 5.6.42 Homebrew
    
    Copyright (c) 2000, 2018, 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.
    
    mysql> exit
    Bye
    liangyufengdeMacBook-Pro:~ liangyufeng$ ps -ef|grep mysql
      501 62433 25300   0  8:23下午 ttys000    0:00.92 ./mysqld
      501 62593 62055   0  9:14下午 ttys001    0:00.00 grep mysql
    liangyufengdeMacBook-Pro:~ liangyufeng$ kill -9 62433
    liangyufengdeMacBook-Pro:~ liangyufeng$ which mysql
    /usr/local/opt/mysql@5.6/bin/mysql
    liangyufengdeMacBook-Pro:~ liangyufeng$ mysqld
    2019-01-11 21:17:22 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
    2019-01-11 21:17:22 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
    2019-01-11 21:17:22 0 [Note] mysqld (mysqld 5.6.42) starting as process 62606 ...
    2019-01-11 21:17:22 62606 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
    2019-01-11 21:17:22 62606 [Note] Plugin 'FEDERATED' is disabled.
    2019-01-11 21:17:22 62606 [Note] InnoDB: Using atomics to ref count buffer pool pages
    2019-01-11 21:17:22 62606 [Note] InnoDB: The InnoDB memory heap is disabled
    2019-01-11 21:17:22 62606 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
    2019-01-11 21:17:22 62606 [Note] InnoDB: Memory barrier is not used
    2019-01-11 21:17:22 62606 [Note] InnoDB: Compressed tables use zlib 1.2.11
    2019-01-11 21:17:22 62606 [Note] InnoDB: Using CPU crc32 instructions
    2019-01-11 21:17:22 62606 [Note] InnoDB: Initializing buffer pool, size = 128.0M
    2019-01-11 21:17:22 62606 [Note] InnoDB: Completed initialization of buffer pool
    2019-01-11 21:17:22 62606 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 35
    2019-01-11 21:17:22 62606 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
    2019-01-11 21:17:22 62606 [Note] InnoDB: Retrying to lock the first data file
    ^C2019-01-11 21:17:23 62606 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 35
    2019-01-11 21:17:23 62606 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
    ^C^C^C2019-01-11 21:17:24 62606 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 35
    2019-01-11 21:17:24 62606 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
    2019-01-11 21:17:25 62606 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 35
    2019-01-11 21:17:25 62606 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
    ^C^C2019-01-11 21:17:26 62606 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 35
    2019-01-11 21:17:26 62606 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
    ^C2019-01-11 21:17:27 62606 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 35
    2019-01-11 21:17:27 62606 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
    2019-01-11 21:17:28 62606 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 35
    2019-01-11 21:17:28 62606 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
    2019-01-11 21:17:29 62606 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 35
    2019-01-11 21:17:29 62606 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
    2019-01-11 21:17:30 62606 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 35
    2019-01-11 21:17:30 62606 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
    2019-01-11 21:17:31 62606 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 35
    2019-01-11 21:17:31 62606 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
    2019-01-11 21:17:32 62606 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 35
    2019-01-11 21:17:32 62606 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
    2019-01-11 21:17:33 62606 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 35
    2019-01-11 21:17:33 62606 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
    2019-01-11 21:17:34 62606 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 35
    2019-01-11 21:17:34 62606 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
    2019-01-11 21:17:35 62606 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 35
    2019-01-11 21:17:35 62606 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
    2019-01-11 21:17:36 62606 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 35
    2019-01-11 21:17:36 62606 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
    2019-01-11 21:17:37 62606 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 35
    2019-01-11 21:17:37 62606 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
    2019-01-11 21:17:38 62606 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 35
    2019-01-11 21:17:38 62606 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
    2019-01-11 21:17:39 62606 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 35
    2019-01-11 21:17:39 62606 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
    2019-01-11 21:17:40 62606 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 35
    2019-01-11 21:17:40 62606 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
    2019-01-11 21:17:41 62606 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 35
    2019-01-11 21:17:41 62606 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
    2019-01-11 21:17:42 62606 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 35
    2019-01-11 21:17:42 62606 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
    Killed: 9
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    liangyufengdeMacBook-Pro:~ liangyufeng$ mysql
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 1
    Server version: 5.6.42 Homebrew
    
    Copyright (c) 2000, 2018, 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.
    
    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | test               |
    +--------------------+
    2 rows in set (0.00 sec)
    
    mysql> use test;
    Database changed
    mysql> show tables;
    Empty set (0.00 sec)
    
    mysql> exit
    Bye
    liangyufengdeMacBook-Pro:~ liangyufeng$ 
    

      使用下面的命令行操作来打开数据库:(如果电脑不关机就没必要输入这句话了,只需要每次电脑关机重启的时候才需要输入一次.MySQL用完也没必要关闭.)   nohup mysqld &

    liangyufengdeMacBook-Pro:~ liangyufeng$ nohup mysqld &
    

      

     

    转载于:https://www.cnblogs.com/liangxiaoji/p/10257641.html

    展开全文
  • TimLiu-iOSgithub排名 https://github.com/trending,github搜索:https://github.com/searchObjective-C版本点击这里 欢迎加入QQ交流群: 594119878使用方法:根据目录关键字搜索,记得包含@,以保证搜索目录关键字...
  • Realm是由Y Combinator孵化的创业团队开源出来的一款可以用于iOS(同样适用于Swift&Objective-C)和Android的跨平台移动数据库。目前最新版是Realm 2.0.2,支持的平台包括Java,Objective-C,Swift,React Native,...
  • 看云电子书归档 2016.4

    2018-09-10 13:15:28
    (译) JSON-RPC 2.0 规范(中文版) Gitee 下载 Github 下载 SourceForge 下载 00后:移动互联网崛起新势力 Gitee 下载 Github 下载 SourceForge 下载 ...2014互联网女皇报告:去适应用户的习惯是...
  • 查询引擎 一、Phoenix 贡献者::Salesforce 简介:这是一个Java中间层,可以让开发者在Apache HBase上执行SQL查询。Phoenix完全使用Java编写,代码位于GitHub上,并且提供了一个客户端可嵌入的JDBC驱动。...
  • 海量的超赞 Linux 软件

    2020-01-13 01:28:03
    点击上方“朱小厮的博客”,选择“设为星标”后台回复”1024“获取公众号专属1024GB资料来源:rrd.me/fDvEd这个仓库收集了对任何用户/开发者都超赞的 Linux 应用软件。...
  • 依赖管理 依赖和包管理库 Composer/Packagist:一个包和依赖管理器Composer Installers:一个多框架... ...Satis:一个静态Composer存储库生成器Composition:一个在运行时检查Composer环境的库Version:语义
  • 一个PHP资源列表,内容包括:库、框架、模板、安全、代码分析、日志、第三方库、配置工具、Web 工具、书籍、电子书、经典博文等等 贡献 详细内容请查看贡献. ... Dependency Management Extras框架 Frameworks...
  • 互联网时代 .NET 会渐渐...为了更好的适应互联网时代的需求,我们公司已经把我们的 .NET 架构无缝移植到 Linux 和 MySQL 平台上了,无论你是在 Windows 上用 Visual Studio,还是在 Linux 上或者是 OSX 上用 MonoDev...
  • vcpkg支持多平台,Windows、Linux以及Mac。自动集成开源第三方C 和 C++ 库,如openssl等。摘自官网:vcpkg未添加到任何环境变量,并且不依赖于Windows注册表或Visual Studio
  • Docker是一个相对较新且发展Swift的项目,它允许创建非常轻便的“虚拟机”。 先决条件 除了基本熟悉命令行和使用文本编辑器之外,本教程不需要其他特定技能。 需要以下服务: Docker Hub (登录-如果尚未注册,...
  • 如果你是一名具有前瞻性的开发者或者想成为一名具有前瞻能力的开发者,那么,是时候开始学习编程了,至少在最好的编程语言中选择一个,类似 Python、Swift、JavaScript、C#、C、Ruby、PHP、Haskell、Java、C++
1 2 3 4 5 ... 18
收藏数 348
精华内容 139
热门标签