时间:2021-07-01 10:21:17 帮助过:24人阅读
? / mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 5.7.11 MySQL Community Server (GPL) Copyright (c) 2000, 2016, 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> STATUS -------------- mysql Ver 14.14 Distrib 5.7.11, for osx10.9 (x86_64) using EditLine wrapper Connection id: 8 Current database: Current user: root@localhost SSL: Not in use Current pager: less Using outfile: ‘‘ Using delimiter: ; Server version: 5.7.11 MySQL Community Server (GPL) Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: utf8 Db characterset: utf8 Client characterset: utf8 Conn. characterset: utf8 UNIX socket: /tmp/mysql.sock Uptime: 8 days 15 hours 1 min 17 sec Threads: 2 Questions: 21 Slow queries: 0 Opens: 114 Flush tables: 1 Open tables: 0 Queries per second avg: 0.000 --------------
3. 这时候, 你对比 mysql.default_socket、mysqli.default_socket、pdo_mysql.default_socket 和 通过 MySQL UNIX socket 发现不一样, 这就是 mysql_connect(); 警告的原因: PHP 配置 mysql 有问题.
4. 重新配置 PHP, 打开php.ini(默认位置是: /private/etc/php.ini )
cd /private/etc/
chmod +rwx php.ini ##修改文件权限
vim php.ini
之后修改mysql.default_socket、mysqli.default_socket、pdo_mysql.default_socket 的值为: /tmp/mysql.sock
(一共修改三处,分别为:mysql.default_socket、mysqli.default_socket、pdo_mysql.default_socket)
注意:
若用 vim php.ini 打开的文件为空(我操作的时候, 就是这样), 说明没有 php.ini 这个文件
这个时候, 你浏览 /etc/ 文件夹下, 会有 php.ini.default 文件, 复制 php.ini.default 重命名为 php.ini , 再用 vim 修改文件内容
cd /private/etc/ cp php.ini.default php.ini ##复制 php.ini.default, 并且重命名 chmod +rwx php.ini ##修改文件权限 vim php.ini
5,重启apache
sudo apachectl restart ##重启 apache
Warning: mysql_connect(): No such file or directory 解决方案总结(操作系统: Mac)
标签:blog bin os x ini rect link word cal 1.4