Mac下如何玩MySQL Server

版权声明:本文为博主原创文章,未经博主允许不得转载。

最近搞事务相关的语句,开始搞select for update了,在ECS上做实验,发现我安装的版本只支持MyISAM,不支持InnoDB,事务没法玩。于是在Mac上安装了一份MySQL Server。

如何安装,如何玩转,看说明书是最好的~

我的机器上,StartupItems安装失败了,也不知道为什么。不过,MySQL Server安装是成功的,所以采用手动模式启动就OK了。

     shell> cd /usr/local/mysql
     shell> sudo ./bin/mysqld_safe
     (ENTER YOUR PASSWORD, IF NECESSARY)
     (PRESS CONTROL-Z)
     shell> bg
     (PRESS CONTROL-D OR ENTER "EXIT" TO EXIT THE SHELL)

You should be able to connect to the MySQL server, for example, by
running `/usr/local/mysql/bin/mysql'.

mysql> show engines;
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine     | Support | Comment                                                        | Transactions | XA   | Savepoints |
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
| InnoDB     | YES     | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |
| MRG_MYISAM | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
| BLACKHOLE  | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |
| CSV        | YES     | CSV storage engine                                             | NO           | NO   | NO         |
| MEMORY     | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |
| FEDERATED  | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |
| ARCHIVE    | YES     | Archive storage engine                                         | NO           | NO   | NO         |
| MyISAM     | DEFAULT | Default engine as of MySQL 3.23 with great performance         | NO           | NO   | NO         |
+------------+---------+----------------------------------------------------------------+--------------+------+------------+

8 rows in set (0.00 sec)

可以看到支持InnoDB

然后就可以开始玩起来啦~~

2.4.10 Installing MySQL on Mac OS X

-----------------------------------

You can install MySQL on Mac OS X 10.3.x (`Panther') or newer using a
Mac OS X binary package in PKG format instead of the binary tarball
distribution. Please note that older versions of Mac OS X (for example,
10.1.x or 10.2.x) are *not* supported by this package.

The package is located inside a disk image (`.dmg') file that you first
need to mount by double-clicking its icon in the Finder. It should then
mount the image and display its contents.

To obtain MySQL, see *Note getting-mysql::.

*Note*: Before proceeding with the installation, be sure to shut down
all running MySQL server instances by either using the MySQL Manager
Application (on Mac OS X Server) or via `mysqladmin shutdown' on the
command line.

To actually install the MySQL PKG file, double-click on the package
icon. This launches the Mac OS X Package Installer, which guides you
through the installation of MySQL.

Due to a bug in the Mac OS X package installer, you may see this error
message in the destination disk selection dialog:

     You cannot install this software on this disk. (null)

If this error occurs, simply click the `Go Back' button once to return
to the previous screen. Then click `Continue' to advance to the
destination disk selection again, and you should be able to choose the
destination disk correctly. We have reported this bug to Apple and it is
investigating this problem.

The Mac OS X PKG of MySQL installs itself into
`/usr/local/mysql-VERSION' and also installs a symbolic link,
`/usr/local/mysql', that points to the new location. If a directory
named `/usr/local/mysql' exists, it is renamed to
`/usr/local/mysql.bak' first. Additionally, the installer creates the
grant tables in the `mysql' database by executing `mysql_install_db'.

The installation layout is similar to that of a `tar' file binary
distribution; all MySQL binaries are located in the directory
`/usr/local/mysql/bin'. The MySQL socket file is created as
`/tmp/mysql.sock' by default. See *Note installation-layouts::.

MySQL installation requires a Mac OS X user account named `mysql'. A
user account with this name should exist by default on Mac OS X 10.2
and up.

If you are running Mac OS X Server, a version of MySQL should already
be installed. The following table shows the versions of MySQL that ship
with Mac OS X Server versions.

*Mac OS X Server       *MySQL Version*
Version*               
10.2-10.2.2            3.23.51
10.2.3-10.2.6          3.23.53
10.3                   4.0.14
10.3.2                 4.0.16
10.4.0                 4.1.10a

This manual section covers the installation of the official MySQL Mac
OS X PKG only. Make sure to read Apple's help information about
installing MySQL: Run the `Help View' application, select `Mac OS X
Server' help, do a search for `MySQL,' and read the item entitled
`Installing MySQL.'

For preinstalled versions of MySQL on Mac OS X Server, note especially
that you should start `mysqld' with `safe_mysqld' instead of
`mysqld_safe' if MySQL is older than version 4.0.

If you previously used Marc Liyanage's MySQL packages for Mac OS X from
`http://www.entropy.ch', you can simply follow the update instructions
for packages using the binary installation layout as given on his pages.

If you are upgrading from Marc's 3.23.x versions or from the Mac OS X
Server version of MySQL to the official MySQL PKG, you also need to
convert the existing MySQL privilege tables to the current format,
because some new security privileges have been added. See *Note
mysql-upgrade::.

If you want MySQL to start automatically during system startup, you
also need to install the MySQL Startup Item. It is part of the Mac OS X
installation disk images as a separate installation package. Simply
double-click the `MySQLStartupItem.pkg' icon and follow the
instructions to install it. The Startup Item need be installed only
once. There is no need to install it each time you upgrade the MySQL
package later.

The Startup Item for MySQL is installed into
`/Library/StartupItems/MySQLCOM'. (Before MySQL 4.1.2, the location was
`/Library/StartupItems/MySQL', but that collided with the MySQL Startup
Item installed by Mac OS X Server.) Startup Item installation adds a
variable `MYSQLCOM=-YES-' to the system configuration file
`/etc/hostconfig'. If you want to disable the automatic startup of
MySQL, simply change this variable to `MYSQLCOM=-NO-'.

On Mac OS X Server, the default MySQL installation bundled with the
operating system uses the variable `MYSQL' in the `/etc/hostconfig'
file. The Sun Microsystems, Inc. "Startup Item" installer disables
this variable by setting it to `MYSQL=-NO-'. This avoids boot time
conflicts with the `MYSQLCOM' variable used by the Sun Microsystems,
Inc. "Startup Item". However, it does not shut down a running MySQL
server. You should do that yourself.

After the installation, you can start up MySQL by running the following
commands in a terminal window. You must have administrator privileges
to perform this task.

If you have installed the Startup Item, use this command:

     shell> sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
     (ENTER YOUR PASSWORD, IF NECESSARY)
     (PRESS CONTROL-D OR ENTER "EXIT" TO EXIT THE SHELL)

If you don't use the Startup Item, enter the following command sequence:

     shell> cd /usr/local/mysql
     shell> sudo ./bin/mysqld_safe
     (ENTER YOUR PASSWORD, IF NECESSARY)
     (PRESS CONTROL-Z)
     shell> bg
     (PRESS CONTROL-D OR ENTER "EXIT" TO EXIT THE SHELL)

You should be able to connect to the MySQL server, for example, by
running `/usr/local/mysql/bin/mysql'.


*Note*: The accounts that are listed in the MySQL grant tables
initially have no passwords.  After starting the server, you should set
up passwords for them using the instructions in *Note
post-installation::.

You might want to add aliases to your shell's resource file to make it
easier to access commonly used programs such as `mysql' and
`mysqladmin' from the command line. The syntax for `bash' is:

     alias mysql=/usr/local/mysql/bin/mysql
     alias mysqladmin=/usr/local/mysql/bin/mysqladmin

For `tcsh', use:

     alias mysql /usr/local/mysql/bin/mysql
     alias mysqladmin /usr/local/mysql/bin/mysqladmin

Even better, add `/usr/local/mysql/bin' to your `PATH' environment
variable. You can do this by modifying the appropriate startup file for
your shell. For more information, see *Note invoking-programs::.

If you are upgrading an existing installation, note that installing a
new MySQL PKG does not remove the directory of an older installation.
Unfortunately, the Mac OS X Installer does not yet offer the
functionality required to properly upgrade previously installed
packages.

To use your existing databases with the new installation, you'll need
to copy the contents of the old data directory to the new data
directory. Make sure that neither the old server nor the new one is
running when you do this. After you have copied over the MySQL database
files from the previous installation and have successfully started the
new server, you should consider removing the old installation files to
save disk space. Additionally, you should also remove older versions of
the Package Receipt directories located in
`/Library/Receipts/mysql-VERSION.pkg'.

时间: 2024-09-01 15:48:29

Mac下如何玩MySQL Server的相关文章

mac下eclipse与mysql建立不了连接

问题描述 mac下eclipse与mysql建立不了连接 在终端下能访问到数据库.但是使用jdbc访问不到. javax.servlet.ServletException: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The dr

MAC下homebre安装mysql

1.执行安装命令 brew install mysql 2.执行完输入mysql会有如下bug ERROR 2002 (HY000): Can not connect to local MySQL server through socket '/tmp/mysql.sock' (2) 3.bug解决方案 unset TMPDIR 4.然后 mysql_install_db --verbose --user=root --basedir="$(brew --prefix mysql)"

mac-在Mac下安装了mysql,密码无法登陆

问题描述 在Mac下安装了mysql,密码无法登陆 下载了mysql官方最新版本,安装好后也记下了生成的临时密码,打开系统偏好设置下的Mysql使其在运行状态,打开终端输入 cd /usr/local/mysql/bin 显示: 之后看网上一些重置密码等等方法完全不行,终端始终不能打开mysql,要输入密码,密码一直不对. 后来想把mysql卸载了重新安装,但根据网上的方法在系统偏好设置里停止运行mysql,在终端输入一堆编码,但终端输入编码又出现让输入密码的状态,根本不能卸载mysql . 因

【MYSQL数据库开发之一】MAC下配置安装数据库-MYSQL

本站文章均为 李华明Himi 原创,转载务必在明显处注明:  转载自[黑米GameDev街区] 原文链接: http://www.himigame.com/mysql/749.html 那么从今天开始陆续会更新数据库和Hibernate框架的博文,也是Himi学习的历程记录,希望大家能共同讨论和研究: OK,本篇简单介绍安装吧,首先到MySQL官方网站: http://www.mysql.com/downloads/ 如上图:点击DOWNLOAD ,进入如下界面,选择对应你的系统对应版本下载即可

MAC下mysql安装配置方法图文教程_Mysql

一.下载MySQL     访问MySQL的官网http://www.mysql.com/downloads/ 然后在页面中会看到"MySQL Community Server"下方有一个"download"点击. 进入MySQL的下载界面(http://www.mysql.com/downloads/mysql/),如果你是用的Mac OS来访问的话那么就会默认为你选好了Mac OS X 平台,而下面罗列的都是在Mac OS上能用的MySQL的版本,如果是用的其他

mac 下卸载mysql的方法

今天在mac上瞎折腾时,把mysql玩坏了,想卸载重装,却发现找不到卸载程序,百度了下,将操作步骤备份于此: cd ~/ sudo rm /usr/local/mysqlsudo rm -rf /usr/local/var/mysql sudo rm -rf /usr/local/mysql* sudo rm -rf /Library/StartupItems/MySQLCOM sudo rm -rf /Library/PreferencePanes/My* vim /etc/hostconfi

数据库-mac下新版mysql编码方式修改

问题描述 mac下新版mysql编码方式修改 看了网上很多的教程,说在[client]标签和[mysqld]标签后加入内容(如下图),但是我加上后数据库启动是可以,就是不能插入语句了. 想问大神有没有完整的教程.!!! 解决方案 解决方案二: 修改mysql中的编码方式Mysql编码方式修改osx下修改mysql编码方式

mac下Apache + MySql + PHP搭建网站开发环境_php技巧

首先为什不自己分别搭建Apache,PHP和MySql的环境呢?这样自己可以了解更多知识,说起来也更酷.可也许因为我懒吧,我是那种"既然有现成的,用就是了"的人.君子生非异也,善假于物也.两千年前的荀子就教导我们,要善于利用工具,我为什么非要自己一点一点配置呢? 哈哈,刚才说了windows下的PHP开发环境我用的是AppServ开发套件,Mac下呢,我用XAMPP.这是致力于推广Apache服务器的非营利性项目--Apache Friends推出的工具.其实XAMPP也有window

mac下配置nginx+php+mysql方法说明

额...本来以为mac下可以用lnmp一键安装包的,但是使用后才发现,竟然不行... 后来使用了大家都推荐的homebrew来安装...具体教程大家可以上网搜,都不算太难... 这里具体要说说的是,安装nginx的问题...如果是用homebrew安装nginx的话,是没办法添加第三方module的...至少我找了好久,也上stackoverflow问了  都没有找到解决方法... 最后木办法,只能手动编译安装nginx,php和mysql 以及pecl的话就通过homebrew来安装... 大