Using Cygwin to compile Mysql clients under Windows _mysql

Source: Internet
Author: User
Tags mysql client readline

Mintty is a small but very practical Cygwin terminal, but there is a serious problem is the inability to invoke interactive Windows native programs, such as Mysql.exe, when you enter the following command in Mintty:

Copy Code code as follows:

$ mysql-uroot-p

Originally Mysql.exe will be prompted to enter a password, but in the Mintty program will hang directly, no longer respond, in fact, even after the-p parameter followed by the password, is the same.

Some programs, such as Python, provide parameter-I, which allows them to enter interactive mode in the terminal, but not all programs have such parameters.

Solution, using the Cygwin version of the MySQL client, but Cygwin did not provide, so just do it yourself compile one!

Download the source package in Http://dev.mysql.com/downloads and unzip it.

Copy Code code as follows:

$ wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.0-m2.tar.gz/from/...
$ tar zxvf mysql-5.5.0-m2.tar.gz
$ CD mysql-5.5.0-m2

Before you start compiling, open the Cygwin installer to install the ReadLine, which replaces MySQL with its own. MySQL Source Bundle bundled ReadLine in Cygwin will be an error.

When you are ready, start the compilation process:

Copy Code code as follows:

$./configure--without-server--without-readline Cflags=-o2 Cxxflags=-o2
$ make
$ make Install

Cygwin compile speed is very slow, and the original *nix system can not compare, so if not idle to panic, it is best not to compile "complex" MySQL Server.

After compiling the MySQL Client, open the MySQL Server in the Windows system and test it with the following command:

Copy Code code as follows:

$ mysql-h127.0.0.1-uroot-p

Why add-h127.0.0.1? By default, the Unix socket file is used to connect to the server without the-h parameter or with-H localhost,mysql, even if you specify the port in the command will be ignored, so it is definitely not connected, the hint can not find/tmp/mysql.sock. With IP or hostname, MySQL uses TCP/IP mode to connect to the server's 3306 port, which is no problem.

For convenience, force the client to use TCP/IP connection mode in the configuration file.

Copy the profile template from the Mysql-5.5.0-m2/support-files to/etc/my.cnf,eg:

Copy Code code as follows:

$ CP support-files/my-medium.cnf/etc/my.cnf

Add Protocol=tcp,eg to [client]:
Copy Code code as follows:

# The following options would be passed to all MySQL clients
[Client]
#password = Your_password
Port = 3306
Socket =/tmp/mysql.sock
protocol = TCP

# # Specifies the default encoding for client connections, note UTF8, not utf-8
# # can be modified to suit your needs
Default-character-set = UTF8

You can then use Mysql-uroot-p to connect directly to the MySQL Server in Windows.

A tangle of garbled questions

Incidentally, most of the people in MySQL are using the UTF-8 code, and so am I. In order to avoid garbled, need to set the character set in the Cygwin/mintty to UTF-8, but it is extremely uncomfortable, so, the Chinese Windows program, will be garbled (such as ping, tracert,nslookup ...), because the Chinese windows The environment uses the GBK character set, there is no way, either switch to E-text Windows, or endure.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.