forked from go-mysql-org/go-mysql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Use the example from the `README.md` and turn it into a `go-mysqlserver` binary that users can run. 2. Add more logging to make it easier to understand what it is doing. This is done both in `go-mysqlserver` as well as the `EmptyHandler` 3. Remove the `server/example` as we already have a example now. 4. Support the minimal set of queries that MySQL Shell `mysqlsh` needs to be able to connect. (tested with MySQL Shell 9.1.0) 5. Change the default version from 5.7.0 to 8.0.11 (first 8.0 GA version)
- Loading branch information
Showing
6 changed files
with
80 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -305,7 +305,6 @@ func main() { | |
} | ||
} | ||
} | ||
|
||
``` | ||
|
||
Another shell | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
"net" | ||
|
||
"github.com/go-mysql-org/go-mysql/server" | ||
) | ||
|
||
func main() { | ||
// Listen for connections on localhost port 4000 | ||
l, err := net.Listen("tcp", "127.0.0.1:4000") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
log.Println("Listening on port 4000, connect with 'mysql -h 127.0.0.1 -P 4000 -u root'") | ||
|
||
// Accept a new connection once | ||
c, err := l.Accept() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
log.Println("Accepted connection") | ||
|
||
// Create a connection with user root and an empty password. | ||
// You can use your own handler to handle command here. | ||
conn, err := server.NewConn(c, "root", "", server.EmptyHandler{}) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
log.Println("Registered the connection with the server") | ||
|
||
// as long as the client keeps sending commands, keep handling them | ||
for { | ||
if err := conn.HandleCommand(); err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
|
||
log.Println("Connection is gone, stopping the server") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters