mac mysql源码安装_Mac OS X 10.15 下源码安装 mysql-8.0.20-macos10.15-x86_64

下载mysql-8.0.20-macos10.15-x86_64.tar.gz 可以从mysql官网下载,如果比较慢,

解压

tar zxvf mysql-8.0.20-macos10.15-x86_64.tar.gz

移动解压后的二进制包到安装目录

sudo mv mysql-8.0.20-macos10.15-x86_64 /usr/local/mysql

在 /usr/local/mysql 目录新建 data目录文件

cd /usr/local/mysql sudo mkdir data

更改 mysql 安装目录所属用户与用户组

cd /usr/local sudo chown -R root:wheel mysql

在启动 mysql 之前,我们先需要指定my.cnf 文件

因为

mysql 5.7 版本开始

my-default.cnf 文件不会自带,需要手动创建。

cd /usr/local/mysql/support-files sudo vi my-default.cnf

/usr/local/mysql/support-files 目录下创建

my-default.cnf

[mysqld]

basedir = /usr/local/mysql

datadir = /usr/local/mysql/data

port = 3306

socket = /usr/local/mysql/data/mysql.sock

log-error = /usr/local/mysql/data/mysqld.log

[client]

socket=/usr/local/mysql/data/mysql.sock

拷贝

my-default.cnf

/etc/my.cnf

sudo cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf

初始化 mysqld

cd /usr/local/mysql sudo bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

其中: basedir 是指你的mysql安装在哪儿了。 (具体需要换成你自己的路径) datadir 是指MySQL后续的数据存放在哪儿。(具体需要换成你自己的路径)

注意: 这儿执行完会生成mysql root账号的密码,后面在客户端连接时,5.7版本需要用到,自己别忘了记录下 类似这种: 其中 Wt#GeUu_q2oJ 就是root的密码。

[Note] A temporary password is generated for root

@localhost: Wt#GeUu_q2oJ

启动MYSQL

cd /usr/local/mysql sudo support-files/mysql.server start

如下:

kingly

@192 data % cd /usr/local/mysql kingly

@192 mysql % sudo support-files/mysql.server start Starting MySQL . SUCCESS!

对应mysqld 启动起来接口

ps aux | grep mysqld

见到如下所示,证明mysql安装成功。

kingly

@192 mysql % ps aux | grep mysqld

kingly 40915 0.6 0.0 4285708 724 s000 S+ 5:47下午 0:00.00 grep --color=auto mysqld _mysql 40907 0.4 2.1 4907248 350300 s000 S 5:46下午 0:00.95 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/mysqld.log --pid-file=/usr/local/mysql/data/192.168.0.103.pid --socket=/usr/local/mysql/data/mysql.sock --port=3306

使用 之前的记住的 Wt#GeUu_q2oJ的密码,测试mysql的链接情况

/usr/local/mysql/bin/mysql -uroot -P3306 -p

kingly

@192 bin % /usr/local/mysql/bin/mysql -uroot -P3306 -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 8

Server version: 8.0.20

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

修改root密码,并为

PASSWORD EXPIRE NEVER 永不过期

mysql> alter user 'root'@'localhost' identified by '12345678' PASSWORD EXPIRE NEVER;

mysql> flush privileges;

mysql> quit;

设置远程访问

允许root用户在任何地方进行远程登录,并具有所有库任何操作权限。

如果出现

提示”Access denied for user ‘root’@’localhost’ (using password: YES)”

mysql> use mysql;

Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed

mysql> select user,host from user;

+------------------+-----------+ | user | host | +------------------+-----------+

| epass | % |

| epass | localhost |

| mysql.infoschema | localhost |

| mysql.session | localhost |

| mysql.sys | localhost |

| root | localhost |

+------------------+-----------+ 6 rows in set (0.00 sec)

mysql>

发现root只有本地权限,

那么,

我们需要给root 加上 127.0.0.1,% 还有指定服务器ip访问的权限,

注意: mysql版本8.0.13,在给新用户授权时,发生了变化

如果出现,

不能直接使用  grant all privileges on *.* to root@'%' identified by '12345678';   //给mysql用户分配远程访问权限

会出现,

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by "12345678"' at line 1

的错误,原因是新版本mysql版本把将创建账户和赋予权限分开了。

应该如下操作:

mysql> use mysql;

mysql> create user 'root'@'%' identified by 'password';

mysql> grant all privileges on *.* to 'root'@'%' with grant option;

mysql> flush privileges;

如果使用 Navicat连接MySQL Server8.0版本时出现Client does not support authentication protocol requested by server;

解决办法:

mysql> use mysql;

mysql> alter user 'root'@'localhost' identified with mysql_native_password by '12345678';

mysql> flush privileges;

如上即可。

加入环境变量,编辑

/etc/profile,这样可以在任何地方用mysql命令了

sudo vi ~/.bash_profile

添加

export PATH=$PATH:/usr/local/mysql//bin

使~/.bash_profile

环境变量生效

source ~/.bash_profile

这个就可以在 任何地方用

mysql 命令了。

mysql -uroot -p

启动、重启与停止,状态

启动

sudo /usr/local/mysql/support-files/mysql.server start

重启

sudo /usr/local/mysql/support-files/mysql.server restart

停止

sudo /usr/local/mysql/support-files/mysql.server stop

查看状态

sudo /usr/local/mysql/support-files/mysql.server status

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Mac OS X 10.15源码安装 mysql-8.0.20-macos10.15-x86_64 https://my.oschina.net/kinglyphp/blog/4281112 博客地址 下载mysql-8.0.20-macos10.15-x86_64.tar.gz 可以从mysql官网下载,如果比较慢, 从https://download.csdn.net/download/long4512524/12427861 中下载 解压 tar zxvf mysql-8.0.20-macos10.15-x86_64.tar.gz 移动解压后的二进制包到安装目录 sudo mv mysql-8.0.20-macos10.15-x86_64 /usr/local/mysql 在 /usr/local/mysql 目录新建 data目录文件 cd /usr/local/mysql sudo mkdir data 更改 mysql 安装目录所属用户与用户组 cd /usr/local sudo chown -R root:wheel mysql 在启动 mysql 之前,我们先需要指定my.cnf 文件 因为 mysql 5.7 版本开始 my-default.cnf 文件不会自带,需要手动创建。 cd /usr/local/mysql/support-files sudo vi my-default.cnf 在 /usr/local/mysql/support-files 目录下创建 my-default.cnf [mysqld] basedir = /usr/local/mysql datadir = /usr/local/mysql/data port = 3306 socket = /usr/local/mysql/data/mysql.sock log-error = /usr/local/mysql/data/mysqld.log [client] socket=/usr/local/mysql/data/mysql.sock 拷贝my-default.cnf到/etc/my.cnf sudo cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf 初始化 mysqld cd /usr/local/mysql sudo bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data 其中: basedir 是指你的mysql安装在哪儿了。 (具体需要换成你自己的路径) datadir 是指MySQL后续的数据存放在哪儿。(具体需要换成你自己的路径) 注意: 这儿执行完会生成mysql root账号的密码,后面在客户端连接时,5.7版本需要用到,自己别忘了记录下 类似这种: 其中 Wt#GeUu_q2oJ 就是root的密码。 [Note] A temporary password is generated for root@localhost: Wt#GeUu_q2oJ 启动MYSQL cd /usr/local/mysql sudo support-files/mysql.server start 如下: kingly@192 data % cd /usr/local/mysql kingly@192 mysql % sudo support-files/mysql.server start Starting MySQL . SUCCESS! 对应mysqld 启动起来接口 ps aux | grep mysqld 见到如下所示,证明mysql安装成功。 kingly@192 mysql % ps aux | grep mysqld kingly 40915 0.6 0.0 4285708 724 s000 S+ 5:47下午 0:00.00 grep --color=auto mysqld _mysql 40907 0.4 2.1 4907248 350300 s000 S 5:46下午 0:00.95 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/mysqld.log --pid-file=/usr/local/mysql/data/192.168.0.103.pid --socket=/usr/local/mysql/data/mysql.sock --port=3306 使用 之前的记住的 Wt#GeUu_q2oJ的密码,测试mysql的链接情况 /usr/local/mysql/bin/mysql -uroot -P3306 -p kingly@192 bin % /usr/local/mysql/bin/mysql -uroot -P3306 -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 8.0.20 Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> 修改root密码,并为 PASSWORD EXPIRE NEVER 永不过期 mysql> alter user 'root'@'localhost' identified by '12345678' PASSWORD EXPIRE NEVER; mysql> flush privileges; mysql> quit; 设置远程访问 允许root用户在任何地方进行远程登录,并具有所有库任何操作权限。 如果出现 提示”Access denied for user ‘root’@’localhost’ (using password: YES)” mysql> use mysql; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> select user,host from user; +------------------+-----------+ | user | host | +------------------+-----------+ | epass | % | | epass | localhost | | mysql.infoschema | localhost | | mysql.session | localhost | | mysql.sys | localhost | | root | localhost | +------------------+-----------+ 6 rows in set (0.00 sec) mysql> 发现root只有本地权限, 那么, 我们需要给root 加上 127.0.0.1,% 还有指定服务器ip访问的权限, 注意: mysql版本8.0.13,在给新用户授权时,发生了变化 如果出现, 不能直接使用 grant all privileges on *.* to root@'%' identified by '12345678'; //给mysql用户分配远程访问权限 会出现, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by "12345678"' at line 1 的错误,原因是新版本mysql版本把将创建账户和赋予权限分开了。 应该如下操作: mysql> use mysql; mysql> create user 'root'@'%' identified by 'password'; mysql> grant all privileges on *.* to 'root'@'%' with grant option; mysql> flush privileges; 如果使用 Navicat连接MySQL Server8.0版本时出现Client does not support authentication protocol requested by server; 解决办法: mysql> use mysql; mysql> alter user 'root'@'localhost' identified with mysql_native_password by '12345678'; mysql> flush privileges; 如上即可。 加入环境变量,编辑 /etc/profile,这样可以在任何地方用mysql命令了 sudo vi ~/.bash_profile 添加 export PATH=$PATH:/usr/local/mysql//bin 使~/.bash_profile环境变量生效 source ~/.bash_profile 这个就可以在 任何地方用 mysql 命令了。 mysql -uroot -p 启动、重启与停止,状态 启动 sudo /usr/local/mysql/support-files/mysql.server start 重启 sudo /usr/local/mysql/support-files/mysql.server restart 停止 sudo /usr/local/mysql/support-files/mysql.server stop 查看状态 sudo /usr/local/mysql/support-files/mysql.server status
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值