Can't set up phpmyadmin on Mac OS High Sierra

柔情痞子 提交于 2021-02-08 10:17:42

问题


I've been some hours trying to set up phpmyadmin in my MacBook Pro, and I get to have in running in localhost, but when it comes to filling the username and password, I get some errors, usually related to SQL. I was wondering if there is any tutorial to follow so I can set it up properly.

Thank you, Álvaro.


回答1:


When you're using the default 'host' value in phpMyAdmin, it tries to connect via socket connection ($cfg['Servers'][$i]['host'] = 'localhost'; is the default, unless you've explicitly set it in config.inc.php). On Mac OS, for some reason PHP and MySQL don't agree about the default location of the socket file.

There are several easy solutions, but for two of them you must first determine the actual path to the socket. The easiest way is to get to the MySQL command prompt. Open 'Terminal' in the Applications -> Utilities folder, then type mysql -u root -p and when prompted, enter your MySQL root password (the default is usually blank). At the MySQL prompt, type status; and you'll see a list of several connection-related settings. Look for one like

UNIX socket: /var/run/mysqld/mysqld.sock

This is the path to the socket. Yours will almost certainly be different than this.

Now, about those ways to fix this:

  1. Change the default socket in PHP. Open the PHP configuration file (likely php.ini) in your favorite text editor and add the correct path to the line mysqli.default_socket =. This change will affect any PHP script using the default system socket path.
  2. Change the socket only for phpMyAdmin. Open the phpMyAdmin configuration file (config.inc.php) in your favorite text editor. Edit or add the line $cfg['Servers'][$i]['socket'] = ''; with the correct path.
  3. Switch the connection type to TCP networking. Again, edit the phpMyAdmin configuration file (config.inc.php) and edit or add the line $cfg['Servers'][$i]['host'] = '127.0.0.1';. This will tell phpMyAdmin to use the TCP networking connection method instead of sockets. Note that your MySQL instances may not listen for incoming TCP connections by default and that your MySQL user root@localhost is not the same as root@127.0.0.1 or root@%.

You should only need one of those solutions, not all three.




回答2:


Try changing the port number. You can use port no 8080 or 3306. It worked for me.



来源:https://stackoverflow.com/questions/50045935/cant-set-up-phpmyadmin-on-mac-os-high-sierra

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!