1.安装MacPorts

MacPorts前称DarwinPorts,是一个软件包管理系统,用来简化Mac OS X和Darwin操作系统上软件的安装。

到这个网站下载MacPorts,并安装

2.使用Mac安装MySQL

sudo port -v install mysql5-server mysql5

如果安装成功,会有以下输出:

...

If this is a new install, in order to setup the database you might want to run:

sudo -u _mysql mysql_install_db5

---> Cleaning mysql5-server

---> Removing work directory for mysql5-server

---> Computing dependencies for mysql5.

---> Cleaning mysql5

---> Removing work directory for mysql5

---> Updating database of binaries: 100.0%

---> Scanning binaries for linking errors: 100.0%

---> No broken files found.

有时,可能会遇到以下错误:

configure: error: C compiler cannot create executables

这个错误是由于没有安装c编译器造成的,可以在xcode中安装

Preferences->Downloads->Components

2.1 初始化数据库

sudo -u _mysql mysql_install_db5

执行成功有以下输出:

xxxx-MacBook-Pro:MHLogin strider$ sudo -u _mysql mysql_install_db5

Installing MySQL system tables...

OK

Filling help tables...

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:

/opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password'

/opt/local/lib/mysql5/bin/mysqladmin -u root -h wmbs-MacBook-Pro.local password 'new-password'

Alternatively you can run:

/opt/local/lib/mysql5/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 /opt/local ; /opt/local/lib/mysql5/bin/mysqld_safe &

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

cd /opt/local/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /opt/local/lib/mysql5/bin/mysqlbug script!

注意MySQL安装到了什么地方。

启动MySQL

sudo mysqld_safe5

131104 19:39:18 mysqld_safe Logging to '/opt/local/var/db/mysql5/wmbs-MacBook-Pro.local.err'.

131104 19:39:18 mysqld_safe Starting mysqld daemon with databases from /opt/local/var/db/mysql5

Ctrl+z,暂停,之后运行命令

bg

是MySQL在后台运行。

2.2命令行,运行以下命令

sudo mysql_secure_installation5

xxxx-MacBook-Pro:~ strider$ sudo mysql_secure_installation5

Password:

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL

SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current

password for the root user. If you've just installed MySQL, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here.

Enter current password for root (enter for none):

OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL

root user without the proper authorisation.

Set root password? [Y/n] y

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

... Success!

By default, a MySQL installation has an anonymous user, allowing anyone

to log into MySQL without having to have a user account created for

them. This is intended only for testing, and to make the installation

go a bit smoother. You should remove them before moving into a

production environment.

Remove anonymous users? [Y/n] y

... Success!

Normally, root should only be allowed to connect from 'localhost'. This

ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y

... Success!

By default, MySQL comes with a database named 'test' that anyone can

access. This is also intended only for testing, and should be removed

before moving into a production environment.

Remove test database and access to it? [Y/n] y

- Dropping test database...

... Success!

- Removing privileges on test database...

... Success!

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

Reload privilege tables now? [Y/n] y

... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MySQL

installation should now be secure.

Thanks for using MySQL!

xxxx-MacBook-Pro:~ strider$

设置root帐户的密码,并且移除test数据库,进行安全设置

2.3 连接数据数据库

sudo mysql5 -uroot -proot

可能有以下错误:

sh-3.2# mysql5 -uroot -proot

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2)

这是由于没有启动mysql server

可以使用mysqld_safe5,bg启动mysql server,并后台运行

sh-3.2# sudo mysqld_safe5

131104 20:30:10 mysqld_safe Logging to '/opt/local/var/db/mysql5/wmbs-MacBook-Pro.local.err'.

131104 20:30:10 mysqld_safe Starting mysqld daemon with databases from /opt/local/var/db/mysql5

^C^Z

[1]+ Stopped(SIGTSTP) sudo mysqld_safe5

sh-3.2# bg

[1] sudo mysqld_safe5 &

sh-3.2# mysql5 -uroot -proot

3. 安装MySQL-python

如果是做python开发,需要安装MySQL-python

pip install MySQL-python==1.2.3

安装成功,会有以下输出:

0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (i386): /opt/local/lib/libcrypto.dylib

ld: warning: ignoring file /opt/local/lib/libssl.dylib, file was built for unsupported file format ( 0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (i386): /opt/local/lib/libssl.dylib

warning: no files found matching 'MANIFEST'

warning: no files found matching 'ChangeLog'

warning: no files found matching 'GPL'

Successfully installed MySQL-python

Cleaning up...

(virtualenv)sh-3.2#

可能会有以下错误:

EnvironmentError: mysql_config not found

解决办法:

cd /opt/local/bin

sudo ln -s /opt/local/lib/mysql5/bin/mysql_config .

注意路径/opt/local/lib/mysql5/bin,根据自己的mysql安装路径相应修改。

*注意mysqld_safe5和mysql5后面的数字是使用MacPosts安装MySQL自动加上的,表明MySQL的版本。

查看mysql的版本:

mysql> status;

mysql 字符集utf8mb4

MYSQL 5.5 之前, UTF8 编码只支持1-3个字节,只支持BMP这部分的unicode编码区, BMP是从哪到哪,到 http://en.wikipedia.org/wiki/Mapping_of_Unicode_characters 这里看,基本就是0000~FFFF这一区。 从MYSQL5.5开始,可支持4个字节UTF编码utf8mb4,一个字符最多能有4字节,所以能支持更多的字符集。

macport mysql_Mac系统中使用MacPorts安装MySQL相关推荐

  1. linux redis数据库安装配置,Linux系统中redis的安装配置步骤

    Linux系统中redis的安装配置步骤 发布时间:2020-06-23 10:13:36 来源:亿速云 阅读:87 作者:Leah 这篇文章将为大家详细讲解有关Linux系统中redis的安装配置步 ...

  2. workerman在linux上怎么运行,linux系统中workerman的安装步骤

    linux系统中workerman的安装步骤,文件,测试,教程,相关文章,错了 linux系统中workerman的安装步骤 易采站长站,站长之家为您整理了linux系统中workerman的安装步骤 ...

  3. 源码安装mysql_CentOS 7中源码安装MySQL 5.7.16 (亲测成功)

    最近在CentOS 7中源码安装MySQL 5.7.16,发现MySQL5.7.6+以后的安装方式真的与以前版本的MySQL安装方式大大的不同呀.不自己安装一把,下面这篇文章是通过自己的安装过程总结的 ...

  4. 在Windows系统中下载并安装Docker-desktop

    在Windows系统中下载并安装Docker-desktop 推荐目录:https://t.cn/A6ApnczU Docker for Windows 在Windows上运行Docker.系统要求, ...

  5. linux 添加重定向域名,Linux系统中Nginx的安装并进行域名认证和重定向

    Linux系统中Nginx的安装并进行域名认证和重定向 本文主要介绍Linux系统中Nginx的安装并进行域名认证和重定向,希望通过本知识点的讲解对大家今后的学习和工作有所帮助,下面进行具体介绍: 1 ...

  6. 双系统中ubuntu的安装方法

    双系统中ubuntu的安装方法 注意:给电脑安装双系统时,一定要先装Windows系统,再安装Linux系统! 原因是电脑开机后,要先执行一段bootloader引导程序:再由引导程序启动操作系统.W ...

  7. CentOS 7中源码安装MySQL 5.7.16 ----已测试验证

    最近在CentOS 7中源码安装MySQL 5.7.6+,发现MySQL5.7.6+以后的安装方式真的与以前版本的MySQL安装方式大大的不同呀.不自己安装一把,你都不知道不同之处在哪,下面这篇文章是 ...

  8. Ubuntu18.04系统中python3.7安装MultiNEAT库

    Ubuntu18.04系统中python3.7安装MultiNEAT库 前言 MultiNEAT介绍 安装问题 boost安装 MultiNEAT安装 安装过程遇到问题及解决方法 前言 MultiNE ...

  9. Linux系统中OpenSSH的安装和配置(转)

    Linux系统中OpenSSH的安装和配置(转) 概述 许多网络程序,如telnet.rsh.rlogin或rexec,用明文(plain text)传送口令和秘密的信息,所以就可利用任何连接到网络上 ...

最新文章

  1. UVA 10494 - If We Were a Child Again(高精度除法和取余)
  2. java里面怎么添加表约束_mysql给表增加约束条件
  3. 给我十分钟带你过完java多线程所有基础知识
  4. Common sql statement
  5. 我是如何使用git把本地代码上传到github上的,值得借鉴
  6. java实验报告实验六,第六周java实验报告四
  7. 华为MDC调试工具使用介绍
  8. 使用electron-builder来打包
  9. coreldraw梯形校正_CorelDRAW改变用形状识别所绘制对象的轮廓
  10. 为什么我旗帜鲜明的反对前后端分离
  11. 3.in_array低性能问题
  12. Stm32学习笔记(1)-利用TIM1产生SPWM波
  13. H5网页微信授权登录
  14. 10步(**10 step**)天才思维模型
  15. java 感想_Java课程感想
  16. error: fatal error: no input files
  17. 引力波数据居然是用 Python 分析的
  18. 每日一滴——更新pycharm_nltk包中模块的安装
  19. 在线教育项目用户登录和注册
  20. JavaWeb——动态页面技术(JSP/EL/JSTL)

热门文章

  1. M36变径钢筋套筒AM36变径钢筋套筒特性及用途
  2. ubuntu启动流程
  3. 希沃白板断网环境免登陆编辑课件
  4. 在线免费图片格式转化各类型都适用
  5. 集成融云直播UI的时候提示_matroska_decode_buffer in KSYMediaPlayer(matroskadec.o)
  6. 中国oracle ocm,【Oracle 10g OCM 巅峰之战】
  7. JavaScript 正则表达式 处理json,json对象的遍历和处理
  8. COleSafeArray二维数组的使用注意
  9. Jmeter-记一次自动化造数引发的BeanShell写入excel实例
  10. PSR规范 (psr-0,psr-1,psr-2,psr-3,psr-4)