我尝试了很多方法在 Ubuntu 22.04 上安装 WordPress。但是,我总是收到错误。
这是关于MySQL的信息:
alireza@OptiPlex-5090:~$ mysql --version
mysql Ver 15.1 Distrib 10.6.12-MariaDB, for debian-linux-gnu (x86_64) using EditLine wrapper
alireza@OptiPlex-5090:~$ sudo apt-get install mysql-server
[sudo] password for alireza:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
galera-4 libconfig-inifiles-perl libdaxctl1 libdbd-mysql-perl libdbi-perl
libmariadb3 libmysqlclient21 libndctl6 libpmem1 libterm-readkey-perl
liburing2 socat
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
mysql-client-8.0 mysql-client-core-8.0 mysql-server-8.0
mysql-server-core-8.0
Suggested packages:
mailx tinyca
The following packages will be REMOVED:
mariadb-client mariadb-client-10.6 mariadb-client-core-10.6 mariadb-server
mariadb-server-10.6 mariadb-server-core-10.6
The following NEW packages will be installed:
mysql-client-8.0 mysql-client-core-8.0 mysql-server mysql-server-8.0
mysql-server-core-8.0
0 upgraded, 5 newly installed, 6 to remove and 0 not upgraded.
Need to get 0 B/21.6 MB of archives.
After this operation, 35.7 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
dpkg: warning: files list file for package 'mysql-apt-config' missing; assuming package has no files currently installed
(Reading database ... 412208 files and directories currently installed.)
Removing mariadb-client (1:10.6.12-0ubuntu0.22.04.1) ...
Removing mariadb-server (1:10.6.12-0ubuntu0.22.04.1) ...
Removing mariadb-server-10.6 (1:10.6.12-0ubuntu0.22.04.1) ...
Removing mariadb-client-10.6 (1:10.6.12-0ubuntu0.22.04.1) ...
Removing mariadb-client-core-10.6 (1:10.6.12-0ubuntu0.22.04.1) ...
Removing mariadb-server-core-10.6 (1:10.6.12-0ubuntu0.22.04.1) ...
Selecting previously unselected package mysql-client-core-8.0.
dpkg: warning: files list file for package 'mysql-apt-config' missing; assuming package has no files currently installed
(Reading database ... 411880 files and directories currently installed.)
Preparing to unpack .../mysql-client-core-8.0_8.0.32-0ubuntu0.22.04.2_amd64.deb ...
Unpacking mysql-client-core-8.0 (8.0.32-0ubuntu0.22.04.2) ...
Selecting previously unselected package mysql-client-8.0.
Preparing to unpack .../mysql-client-8.0_8.0.32-0ubuntu0.22.04.2_amd64.deb ...
Unpacking mysql-client-8.0 (8.0.32-0ubuntu0.22.04.2) ...
Selecting previously unselected package mysql-server-core-8.0.
Preparing to unpack .../mysql-server-core-8.0_8.0.32-0ubuntu0.22.04.2_amd64.deb ...
Unpacking mysql-server-core-8.0 (8.0.32-0ubuntu0.22.04.2) ...
Selecting previously unselected package mysql-server-8.0.
Preparing to unpack .../mysql-server-8.0_8.0.32-0ubuntu0.22.04.2_amd64.deb ...
Downgrade from (at least) 10.6 to 5.7 is not possible.
Warning: /etc/mysql/FROZEN already exists
MySQL has been frozen to prevent damage to your system. Please see /etc/mysql/FROZEN for help.
Unpacking mysql-server-8.0 (8.0.32-0ubuntu0.22.04.2) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_8.0.32-0ubuntu0.22.04.2_all.deb ...
Unpacking mysql-server (8.0.32-0ubuntu0.22.04.2) ...
Setting up mysql-client-core-8.0 (8.0.32-0ubuntu0.22.04.2) ...
Setting up mysql-server-core-8.0 (8.0.32-0ubuntu0.22.04.2) ...
Setting up mysql-client-8.0 (8.0.32-0ubuntu0.22.04.2) ...
Setting up mysql-server-8.0 (8.0.32-0ubuntu0.22.04.2) ...
Installing new version of config file /etc/mysql/debian-start ...
MySQL has been frozen to prevent damage to your system. Please see /etc/mysql/FROZEN for help.
Setting up mysql-server (8.0.32-0ubuntu0.22.04.2) ...
Processing triggers for man-db (2.10.2-1) ...
alireza@OptiPlex-5090:~$ sudo service mysql start
alireza@OptiPlex-5090:~$ sudo service mysql status
● mysql.service - LSB: Start and stop the mysql database server daemon
Loaded: loaded (/etc/init.d/mysql; enabled; vendor preset: enabled)
Active: active (exited) since Tue 2023-04-11 10:06:27 +03; 7s ago
Docs: man:systemd-sysv-generator(8)
Process: 38901 ExecStart=/etc/init.d/mysql start (code=exited, status=0/SUC>
CPU: 1ms
Apr 11 10:06:27 OptiPlex-5090 systemd[1]: Starting LSB: Start and stop the mysq>
Apr 11 10:06:27 OptiPlex-5090 systemd[1]: Started LSB: Start and stop the mysql>
lines 1-9/9 (END)...skipping...
alireza@OptiPlex-5090:~$ mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
alireza@OptiPlex-5090:~$
答案1
根据您在问题和评论中分享的内容,您似乎造成了一些混乱。最初您安装了 MariaDB,然后安装了 MySQL。在某个时候,您得到了ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
,经过一些测试后,您开始得到mysql: command not found
。如果您的数据库中没有任何重要内容,我建议您进行一些清理并重新安装 MySQL 服务器和客户端。
清理
警告:这些命令将删除存储在 MySQL 服务器上的所有数据!
sudo apt purge mysql-*
sudo apt purge mariadb-*
sudo apt autoremove
sudo rm -rf /etc/mysql
sudo rm -rf /var/lib/mysql
sudo rm -rf /var/log/mysql
安装
sudo apt install mysql-server
sudo apt install mysql-client
用法
sudo mysql