安装启用phpmyadmin

1.下载phpmyadmin,可以下载到你想放置的网站目录下,前提是你的mysql、php和web服务器(nginx/httpd/litespeed/IIS等)安装好。

wget  https://files.phpmyadmin.net/phpMyAdmin/5.0.2/phpMyAdmin-5.0.2-all-languages.zip
unzip phpMyAdmin*
mv phpMyAdmin-5.0.2-all-languages pma

2.查询mysql的socket地址,用于后面对接php中的设置.UNIX socket: /var/lib/mysql/mysql.sock

mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.19-10 Percona Server (GPL), Release 10, Revision f446c04

Copyright (c) 2009-2020 Percona LLC and/or its affiliates
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> STATUS;
--------------
mysql  Ver 8.0.19-10 for Linux on x86_64 (Percona Server (GPL), Release 10, Revision f446c04)

Connection id:          10
Current database:
Current user:           root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         8.0.19-10 Percona Server (GPL), Release 10, Revision f446c04
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    utf8
Db     characterset:    utf8
Client characterset:    utf8
Conn.  characterset:    utf8
UNIX socket:            /var/lib/mysql/mysql.sock
Binary data as:         Hexadecimal
Uptime:                 55 min 28 sec

Threads: 2  Questions: 11  Slow queries: 0  Opens: 115  Flush tables: 3  Open tables: 35  Queries per second avg: 0.003
--------------

mysql> 

3.修改php.ini中的mysqli.default_socket和pdo_mysql.default_socket设置为对应的/var/lib/mysql/mysql.sock

vi  /etc/php.ini
mysqli.default_socket = /var/lib/mysql/mysql.sock 
pdo_mysql.default_socket = /var/lib/mysql/mysql.so

你也可以设置mysql配置文件my.cnf

vi /etc/my.cnf

[client]
socket          = /var/lib/mysql/mysql.sock
[mysqld]
socket          = /var/lib/mysql/mysql.sock

至此,重启php或httpd就可以登录phpmyadmin.下一步我们讨论优化lnmp

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注