2014年7月15日星期二

MAC_017:安装和使用MySQL

开发运行环境:MAC OS X 10.9.4 + MySQL 5.6.19

我下载的是压缩包:mysql-5.6.19-osx10.7-x86_64.tar.gz,之所以没有使用.dmg格式的安装包,是因为卸载时比较麻烦。

1. tar -xzvf mysql-5.6.19-osx10.7-x86_64.tar.gz

2. sudo mv mysql-5.1.45-osx10.6-x86_64 /usr/local/mysql

3. cd /usr/local

4. sudo chown -R mysql:mysql mysql

5. cd mysql

6. 安装数据库:sudo scripts/mysql_install_db --user=mysql

7. sudo chown -R root .

8. sudo chown -R mysql data

9. 修改/etc/profile文件,把/usr/local/mysql/bin加到PATH路径中。

10. cd bin

11. 启动MySQL:sudo ./mysqld_safe

12. 修改root密码:sudo ./mysql_secure_installation
root密码默认为空,不太安全,根据提示酌情配置。

13. sudo ./mysql -u root -p
输入刚才设置的root密码来登录mysql。

14. 停止MySQL:sudo ./mysqld_safe stop

为了以后对比和查看,我把第6步的详细输出复制如下:

Installing MySQL system tables...2014-07-15 09:31:48 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-07-15 09:31:48 18180 [Note] InnoDB: Using atomics to ref count buffer pool pages
2014-07-15 09:31:48 18180 [Note] InnoDB: The InnoDB memory heap is disabled
2014-07-15 09:31:48 18180 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-07-15 09:31:48 18180 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-07-15 09:31:48 18180 [Note] InnoDB: Using CPU crc32 instructions
2014-07-15 09:31:48 18180 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-07-15 09:31:48 18180 [Note] InnoDB: Completed initialization of buffer pool
2014-07-15 09:31:48 18180 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2014-07-15 09:31:48 18180 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2014-07-15 09:31:48 18180 [Note] InnoDB: Database physically writes the file full: wait...
2014-07-15 09:31:48 18180 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2014-07-15 09:31:48 18180 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2014-07-15 09:31:48 18180 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2014-07-15 09:31:48 18180 [Warning] InnoDB: New log files created, LSN=45781
2014-07-15 09:31:48 18180 [Note] InnoDB: Doublewrite buffer not found: creating new
2014-07-15 09:31:48 18180 [Note] InnoDB: Doublewrite buffer created
2014-07-15 09:31:48 18180 [Note] InnoDB: 128 rollback segment(s) are active.
2014-07-15 09:31:48 18180 [Warning] InnoDB: Creating foreign key constraint system tables.
2014-07-15 09:31:48 18180 [Note] InnoDB: Foreign key constraint system tables created
2014-07-15 09:31:48 18180 [Note] InnoDB: Creating tablespace and datafile system tables.
2014-07-15 09:31:48 18180 [Note] InnoDB: Tablespace and datafile system tables created.
2014-07-15 09:31:48 18180 [Note] InnoDB: Waiting for purge to start
2014-07-15 09:31:48 18180 [Note] InnoDB: 5.6.19 started; log sequence number 0
2014-07-15 09:31:49 18180 [Note] Binlog end
2014-07-15 09:31:49 18180 [Note] InnoDB: FTS optimize thread exiting.
2014-07-15 09:31:49 18180 [Note] InnoDB: Starting shutdown...
2014-07-15 09:31:50 18180 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK

Filling help tables...2014-07-15 09:31:50 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-07-15 09:31:50 18185 [Note] InnoDB: Using atomics to ref count buffer pool pages
2014-07-15 09:31:50 18185 [Note] InnoDB: The InnoDB memory heap is disabled
2014-07-15 09:31:50 18185 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-07-15 09:31:50 18185 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-07-15 09:31:50 18185 [Note] InnoDB: Using CPU crc32 instructions
2014-07-15 09:31:50 18185 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-07-15 09:31:50 18185 [Note] InnoDB: Completed initialization of buffer pool
2014-07-15 09:31:50 18185 [Note] InnoDB: Highest supported file format is Barracuda.
2014-07-15 09:31:50 18185 [Note] InnoDB: 128 rollback segment(s) are active.
2014-07-15 09:31:50 18185 [Note] InnoDB: Waiting for purge to start
2014-07-15 09:31:50 18185 [Note] InnoDB: 5.6.19 started; log sequence number 1625977
2014-07-15 09:31:50 18185 [Note] Binlog end
2014-07-15 09:31:50 18185 [Note] InnoDB: FTS optimize thread exiting.
2014-07-15 09:31:50 18185 [Note] InnoDB: Starting shutdown...
2014-07-15 09:31:51 18185 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

  ./bin/mysqladmin -u root password 'new-password'
  ./bin/mysqladmin -u root -h MaPingdeMacBook-Pro.local password 'new-password'

Alternatively you can run:

  ./bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

  cd . ; ./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

  cd mysql-test ; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as ./my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

参考文献:
1. http://blog.csdn.net/mr_von/article/details/6169396
2. http://blog.csdn.net/mr_von/article/details/6169394
3. http://blog.csdn.net/mr_von/article/details/6169397
4. http://dev.mysql.com/doc/refman/5.1/en/binary-installation.html

没有评论: