本文主要讲解“在MAC上安装MYSQL的步骤是什么”,文中的讲解内容简单明了,易学易懂。请跟随边肖的思路,一起学习学习“在MAC上安装MYSQL的步骤是什么”。
MAC如何安装MYSQL?下载地址:https://downloads.mysql.com/archives/community/.
百度网盘下载:链接:https://pan.baidu.com/s/1nceFzJKK7_dJh3gUAtVgWw密码:qm5z。
00-1010双击下载的dmg文件,会弹出pkg弹出框。双击pkg图标进入安装界面。在安装界面上一路继续,安装成功。
00-1010步骤1:切换到终端的根目录,编辑。/.bash_profile文件。
~cd~
~vim。/.bash_profile第2步,进入vim编辑环境,按I进入插入模式,然后回车。
export path=$ PATH :/usr/local/MySQL/bin
导出路径=$ path :/usr/local/MySQL/support-files步骤3:按esc退出插入模式,输入:wq保存配置文件。
:wq第四步:在终端界面输入以下命令,使配置文件的修改生效,检查环境变量是否设置成功。
~echo$PATH
/usr/local/bin :/usr/bin :/bin :/usr/sbin :/sbin
~来源~/。bash_profile
~echo$PATH
/usr/local/bin :/usr/bin :/bin :/usr/sbin :/sbin :/usr/local/MySQL/bin :/usr/local/MySQL/support-files
~
安装
检查MYSQL的服务状态。
~sudomysql.serverstatus
密码:
错误!MYSQLisnotrunning启动MySQL服务。
~sudomysql.serverstart
StartingMySQL。logging to '/usr/local/MySQL/data/mj . local . err '。
成功!停止MYSQL服务。
~sudomysql.serverstop
ShuttingdownMySQL。成功!重新启动MYSQL服务。
~sudomysql.serverrestart
错误!找不到MySQLserverPIDfilecouldnotbefound!
StartingMySQL。不间断空格
;SUCCESS!
启动
第一步,终端界面下输入
➜ ~ sudo mysql.server start Starting MySQL .Logging to '/usr/local/mysql/data/mj.local.err'. SUCCESS!
第二步,启动MYSQL服务,启动成功后继续输入
➜ ~ mysql -u root -p
第三步,直接回车,进入数据库,看到以下欢迎界面
Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.41 MySQL Community Server (GPL) Copyright (c) 2000, 2018, 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>
备注:默认安装成功后没有初始密码,所以密码不用输入,直接回车即可。
初始化设置
设置初始密码,进入mysql数据库之后执行下面的语句,设置当前root用户的密码为root
➜ ~ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.6.41 MySQL Community Server (GPL) Copyright (c) 2000, 2018, 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> set password = password('root'); Query OK, 0 rows affected (0.01 sec) mysql>
退出MYSQL的界面
mysql> exit Bye ➜ ~
配置
进入到 /usr/local/mysql/support-files
目录,里面有个文件my-default.cnf
➜ ~ cd /usr/local/mysql/support-files ➜ support-files ll total 64 -rwxr-xr-x 1 root wheel 1.1K 6 15 2018 binary-configure -rw-r--r-- 1 root wheel 773B 6 15 2018 magic -rw-r--r-- 1 root wheel 1.1K 6 15 2018 my-default.cnf -rwxr-xr-x 1 root wheel 894B 6 15 2018 mysql-log-rotate -rwxr-xr-x 1 root wheel 10K 6 15 2018 mysql.server -rwxr-xr-x 1 root wheel 1.0K 6 15 2018 mysqld_multi.server ➜ support-files
将目录下的my-default.cnf文件复制到桌面上,改名为my.cnf,
➜ support-files ll total 64 -rwxr-xr-x 1 root wheel 1.1K 6 15 2018 binary-configure -rw-r--r-- 1 root wheel 773B 6 15 2018 magic -rw-r--r-- 1 root wheel 1.1K 6 15 2018 my-default.cnf -rwxr-xr-x 1 root wheel 894B 6 15 2018 mysql-log-rotate -rwxr-xr-x 1 root wheel 10K 6 15 2018 mysql.server -rwxr-xr-x 1 root wheel 1.0K 6 15 2018 mysqld_multi.server ➜ support-files cp my-default.cnf /Users/a1/Desktop/my.cnf
将内容替换为下面的内容
[mysqld] default-storage-engine=INNODB character-set-server=utf8 port = 3306 [client] default-character-set=utf8
将修改后的my.cnf文件复制到/etc
目录下,重启MYSQL
➜ /etc cp /Users/a1/Desktop/my.cnf ./ cp: ./my.cnf: Permission denied ➜ /etc sudo cp /Users/a1/Desktop/my.cnf ./ Password: ➜ /etc ll total 1064 ...... -rw------- 1 root wheel 7.3K 2 29 14:10 master.passwd -rw-r--r-- 1 root wheel 1.2K 5 17 17:24 my.cnf -rw-r--r-- 1 root wheel 11B 2 29 14:43 nanorc -rw-r--r-- 1 root wheel 53B 2 29 14:09 networks ...... ➜ /etc
备注:拷贝文件到etc目录需要系统权限,因此需要在命令前加sudo
检测修改结果
➜ ~ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.6.41 MySQL Community Server (GPL) Copyright (c) 2000, 2018, 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> show variables like '%char%'; +--------------------------+-----------------------------------------------------------+ | Variable_name | Value | +--------------------------+-----------------------------------------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/local/mysql-5.6.41-macos10.13-x86_64/share/charsets/ | +--------------------------+-----------------------------------------------------------+ 8 rows in set (0.01 sec) mysql>
备注:此时不输入密码就登录不了数据库了,必须使用修改后的密码登录数据库了,并且数据库的字符集编码信息已经修改了。
感谢各位的阅读,以上就是“MAC上安装MYSQL的步骤是什么”的内容了,经过本文的学习后,相信大家对MAC上安装MYSQL的步骤是什么这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是,小编将为大家推送更多相关知识点的文章,欢迎关注!
内容来源网络,如有侵权,联系删除,本文地址:https://www.230890.com/zhan/42847.html