Ubuntu 16.04 和 mysql 的乐趣

Ubuntu 16.04 和 mysql 的乐趣

如果您能顺利读完这篇文章并给我一些想法,我要提前感谢您。很多。

我在 64 位 Dell 1820 上使用 Ubuntu 16.04。它与 Windows 双重启动,自从 16.04 发布以来我一直在使用这个设置。到目前为止,我在此设置中还没有使用过 Apache、PHP 或 MySQL。

我想设置一个本地 WordPress,因此我使用了名为 ampps 的“一键式”解决方案。这个东西在一个独立的 LAMP 中捆绑了 400 多个程序。然而,PHP 的默认版本是 5.5,许多应用程序(也许是大多数)通过 ampps 仪表板报告说他们无法使用该版本。我找到了如何将其切换到 PHP 7,随后 WordPress 通知我:

Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

他们的支持系统和论坛上的大量帖子让我一无所获,所以我来到了这里。

事实证明 ampps 默认设置:

  1. 7.0 或 7.1 中没有 php.ini 文件

  2. PHP 5.3和5.5中有ini文件

  3. 打开ini文件通过WINE路由,并在记事本版本中打开。这是一个危险信号吗?

所以我想,管它呢,我已经有了自己的 MySQL 和 PHP 7 作为 Ubuntu 16.04 的一部分。我可以安装和配置 Apache。虽然已经过去四五年了,但我已经做到了。我尝试直接打开mysql:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

我就是这样得知的我没有/var/run/mysqld/mysqld.sock。我什至没有 /var/run/mysqld!

盲目地在互联网上摸索,我发现我应该检查/etc/mysql/my.cnf。但这个文件只有一行:

!includedir /etc/mysql/conf.d/

conf.d/mysql.conf 中的所有内容是:

[mysql]

所以我将端口和本地主机放入 my.cnf 中,此时我收到了一个新的致命错误。

重启后:

malikarumi@Tetuoan2:~$ mysql mysql: [ERROR] Found option without preceding group in config file /etc/mysql/my.cnf at line 19! mysql: [ERROR] Fatal error in defaults handling. Program aborted! malikarumi@Tetuoan2:~$

port=3306 # this is line 19 bind-address=127.0.0.1

结果我不得不把 [mysql] 放在 my.cnf 的第一行。现在我又回到了起点——无处可去。

我决定删除 mysql 5.6 并重新安装来重新开始。好吧,这也不顺利:

malikarumi@Tetuoan2:~$ sudo apt-get install mysql-server Reading package lists... Done' 'Building dependency tree
Reading state information... Done The following packages were automatically installed and are no longer required: libmircommon5 linux-headers-4.4.0-78 linux-headers-4.4.0-78-generic linux-headers-4.4.0-79 linux-headers-4.4.0-79-generic linux-image-4.4.0-78-generic linux-image-4.4.0-79-generic linux-image-extra-4.4.0-78-generic linux-image-extra-4.4.0-79-generic linux-signed-image-4.4.0-78-generic linux-signed-image-4.4.0-79-generic Use 'sudo apt autoremove' to remove them. The following additional packages will be installed: libevent-core-2.0-5 libhtml-template-perl mysql-client-5.7 mysql-client-core-5.7 mysql-server-5.7 mysql-server-core-5.7 Suggested packages: libipc-sharedcache-perl tinyca The following packages will be REMOVED: mysql-client-core-5.6 mysql-server-core-5.6 The following NEW packages will be installed: libevent-core-2.0-5 libhtml-template-perl mysql-client-5.7 mysql-client-core-5.7 mysql-server mysql-server-5.7 mysql-server-core-5.7 0 upgraded, 7 newly installed, 2 to remove and 0 not upgraded. Need to get 18.3 MB of archives. After this operation, 113 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 mysql-client-core-5.7 amd64 5.7.18-0ubuntu0.16.04.1 [6,340 kB] Get:2 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 mysql-server-core-5.7 amd64 5.7.18-0ubuntu0.16.04.1 [7,566 kB] Get:3 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 mysql-client-5.7 amd64 5.7.18-0ubuntu0.16.04.1 [1,725 kB] Get:4 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libevent-core-2.0-5 amd64 2.0.21-stable-2ubuntu0.16.04.1 [70.6 kB] Get:5 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 mysql-server-5.7 amd64 5.7.18-0ubuntu0.16.04.1 [2,554 kB] Get:6 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 libhtml-template-perl all 2.95-2 [60.4 kB] Get:7 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 mysql-server all 5.7.18-0ubuntu0.16.04.1 [10.8 kB] Fetched 18.3 MB in 24s (746 kB/s)
Preconfiguring packages ... dpkg: mysql-client-core-5.6: dependency problems, but removing anyway as you requested: akonadi-backend-mysql depends on mysql-client-core-5.7 | virtual-mysql-client-core; however: Package mysql-client-core-5.7 is not installed. Package virtual-mysql-client-core is not installed. Package mysql-client-core-5.6 which provides virtual-mysql-client-core is to be removed.

(Reading database ... 374021 files and directories currently installed.) Removing mysql-client-core-5.6 (5.6.31-0ubuntu0.15.10.1) ... Processing triggers for man-db (2.7.5-1) ... Selecting previously unselected package mysql-client-core-5.7. (Reading database ... 374013 files and directories currently installed.) Preparing to unpack .../mysql-client-core-5.7_5.7.18-0ubuntu0.16.04.1_amd64.deb ... Unpacking mysql-client-core-5.7 (5.7.18-0ubuntu0.16.04.1) ... Processing triggers for man-db (2.7.5-1) ... dpkg: mysql-server-core-5.6: dependency problems, but removing anyway as you requested: akonadi-backend-mysql depends on mysql-server-core-5.7 | virtual-mysql-server-core; however: Package mysql-server-core-5.7 is not installed. Package virtual-mysql-server-core is not installed. Package mysql-server-core-5.6 which provides virtual-mysql-server-core is to be removed.

(Reading database ... 374022 files and directories currently installed.) Removing mysql-server-core-5.6 (5.6.31-0ubuntu0.15.10.1) ... Processing triggers for man-db (2.7.5-1) ... Selecting previously unselected package mysql-server-core-5.7. (Reading database ... 373927 files and directories currently installed.) Preparing to unpack .../mysql-server-core-5.7_5.7.18-0ubuntu0.16.04.1_amd64.deb ... Unpacking mysql-server-core-5.7 (5.7.18-0ubuntu0.16.04.1) ... Selecting previously unselected package mysql-client-5.7. Preparing to unpack .../mysql-client-5.7_5.7.18-0ubuntu0.16.04.1_amd64.deb ... Unpacking mysql-client-5.7 (5.7.18-0ubuntu0.16.04.1) ... Selecting previously unselected package libevent-core-2.0-5:amd64. Preparing to unpack .../libevent-core-2.0-5_2.0.21-stable-2ubuntu0.16.04.1_amd64.deb ... Unpacking libevent-core-2.0-5:amd64 (2.0.21-stable-2ubuntu0.16.04.1) ... Selecting previously unselected package mysql-server-5.7. Preparing to unpack .../mysql-server-5.7_5.7.18-0ubuntu0.16.04.1_amd64.deb ... Unpacking mysql-server-5.7 (5.7.18-0ubuntu0.16.04.1) ... Selecting previously unselected package libhtml-template-perl. Preparing to unpack .../libhtml-template-perl_2.95-2_all.deb ... Unpacking libhtml-template-perl (2.95-2) ... Selecting previously unselected package mysql-server. Preparing to unpack .../mysql-server_5.7.18-0ubuntu0.16.04.1_all.deb ... Unpacking mysql-server (5.7.18-0ubuntu0.16.04.1) ... Processing triggers for man-db (2.7.5-1) ... Processing triggers for libc-bin (2.23-0ubuntu9) ... /sbin/ldconfig.real: File /usr/local/lib/libQtCore.so is empty, not checked. /sbin/ldconfig.real: /lib/x86_64-linux-gnu/libssl.so.1.0.0 is not a symbolic link

/sbin/ldconfig.real: /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 is not a symbolic link

Processing triggers for systemd (229-4ubuntu17) ... Processing triggers for ureadahead (0.100.0-19) ... ureadahead will be reprofiled on next reboot Setting up mysql-client-core-5.7 (5.7.18-0ubuntu0.16.04.1) ... Setting up mysql-server-core-5.7 (5.7.18-0ubuntu0.16.04.1) ... Setting up mysql-client-5.7 (5.7.18-0ubuntu0.16.04.1) ... Setting up libevent-core-2.0-5:amd64 (2.0.21-stable-2ubuntu0.16.04.1) ... Setting up mysql-server-5.7 (5.7.18-0ubuntu0.16.04.1) ... update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode Renaming removed key_buffer and myisam-recover options (if present) insserv: warning: script 'K01ampps' missing LSB tags and overrides insserv: warning: script 'K01httpd' missing LSB tags and overrides insserv: Script mongod is broken: incomplete LSB comment. insserv: missing必需的开始:'条目:即使为空,也请添加。 insserv:缺少Required-Stop:' entry: please add even if empty. insserv: Script mongod is broken: incomplete LSB comment. insserv: missing必需的开始:'条目:即使为空,也请添加。 insserv:缺少Required-Stop:' entry: please add even if empty. insserv: Script mongod is broken: incomplete LSB comment. insserv: missing必需的开始:'条目:即使为空,也请添加。 insserv:缺少Required-Stop:' entry: please add even if empty. insserv: Script mongod is broken: incomplete LSB comment. insserv: missing必需的开始:'条目:即使为空,也请添加。 insserv:缺少Required-Stop:' entry: please add even if empty. insserv: Script mongod is broken: incomplete LSB comment. insserv: missing必需的开始:'条目:即使为空,也请添加。 insserv:缺少Required-Stop:' entry: please add even if empty. insserv: Script mongod is broken: incomplete LSB comment. insserv: missing必需的开始:'条目:即使为空,也请添加。 insserv:缺少Required-Stop:' entry: please add even if empty. insserv: Script mongod is broken: incomplete LSB comment. insserv: missing必需的开始:'条目:即使为空,也请添加。 insserv:缺少Required-Stop:' entry: please add even if empty. insserv: script mysql: service mysql already provided! insserv: exiting now! update-rc.d: error: insserv rejected the script header dpkg: error processing package mysql-server-5.7 (--configure): subprocess installed post-installation script returned error exit status 1' 设置 libhtml-template-perl (2.95-2) ... dpkg:依赖性问题阻止配置 mysql-server:mysql-server 依赖于 mysql-server-5.7;但是:软件包 mysql-server-5.7 尚未配置。`

dpkg: error processing package mysql-server (--configure): dependency problems - leaving unconfigured No apport report written because the error message indicates its a followup error from a previous failure. Processing triggers for libc-bin (2.23-0ubuntu9) ... /sbin/ldconfig.real: File /usr/local/lib/libQtCore.so is empty, not checked. /sbin/ldconfig.real: /lib/x86_64-linux-gnu/libssl.so.1.0.0 is not a symbolic link

/sbin/ldconfig.real: /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 is not a symbolic link

Processing triggers for systemd (229-4ubuntu17) ... Processing triggers for ureadahead (0.100.0-19) ... Errors were encountered while processing: mysql-server-5.7 mysql-server E: Sub-process /usr/bin/dpkg returned an error code (1) malikarumi@Tetuoan2:~$

Canonical/Ubuntu 系统向我推荐了错误跟踪器: https://bugs.launchpad.net/ubuntu/+source/mysql-5.7/+bug/1623440

但此问题被视为“已过期” - 未修复 - 因为 60 天没有任何活动!

最后,我发现了命令 apt-show-versions,(从这里:dpkg 不会安装任何软件包)所以我尝试看看我能找到什么:

malikarumi@Tetuoan2:~$ apt-show-versions The program 'apt-show-versions' is currently not installed. You can install it by typing: sudo apt install apt-show-versions malikarumi@Tetuoan2:~$ sudo apt install apt-show-versions [sudo] password for malikarumi: Reading package lists... Done Building dependency tree
Reading state information... Done The following NEW packages will be installed: apt-show-versions 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. 2 not fully installed or removed. Need to get 29.6 kB of archives. After this operation, 163 kB of additional disk space will be used. Get:1 http://us.archive.ubuntu.com/ubuntu xenial/universe amd64 apt-show-versions all 0.22.7 [29.6 kB] Fetched 29.6 kB in 0s (44.9 kB/s)
Selecting previously unselected package apt-show-versions. (Reading database ... 309531 files and directories currently installed.) Preparing to unpack .../apt-show-versions_0.22.7_all.deb ... Unpacking apt-show-versions (0.22.7) ... Processing triggers for man-db (2.7.5-1) ... Setting up mysql-server-5.7 (5.7.18-0ubuntu0.16.04.1) ... Renaming removed key_buffer and myisam-recover options (if present) insserv: warning: script 'K01ampps' missing LSB tags and overrides insserv: warning: script 'K01httpd' missing LSB tags and overrides insserv: Script mongod is broken: incomplete LSB comment. insserv: missing
必需的开始:'条目:即使为空,也请添加。 insserv:缺少Required-Stop:' entry: please add even if empty. insserv: Script mongod is broken: incomplete LSB comment. insserv: missing必需的开始:'条目:即使为空,也请添加。 insserv:缺少Required-Stop:' entry: please add even if empty. insserv: Script mongod is broken: incomplete LSB comment. insserv: missing必需的开始:'条目:即使为空,也请添加。 insserv:缺少Required-Stop:' entry: please add even if empty. insserv: Script mongod is broken: incomplete LSB comment. insserv: missing必需的开始:'条目:即使为空,也请添加。 insserv:缺少Required-Stop:' entry: please add even if empty. insserv: Script mongod is broken: incomplete LSB comment. insserv: missing必需的开始:'条目:即使为空,也请添加。 insserv:缺少Required-Stop:' entry: please add even if empty. insserv: Script mongod is broken: incomplete LSB comment. insserv: missing必需的开始:'条目:即使为空,也请添加。 insserv:缺少Required-Stop:' entry: please add even if empty. insserv: Script mongod is broken: incomplete LSB comment. insserv: missing必需的开始:'条目:即使为空,也请添加。插入服务:缺失Required-Stop:' entry: please add even if empty. insserv: script mysql: service mysql already provided! insserv: exiting now! update-rc.d: error: insserv rejected the script header dpkg: error processing package mysql-server-5.7 (--configure): subprocess installed post-installation script returned error exit status 1 dpkg: dependency problems prevent configuration of mysql-server: mysql-server depends on mysql-server-5.7; however: Package mysql-server-5.7 is not configured yet.

dpkg: error processing package mysql-server (--configure): dependency problems - leaving unconfigured Setting up apt-show-versions (0.22.7) ... No apport report written because the error message indicates its a followup error from a previous failure. ** initializing cache. This may take a while ** Errors were encountered while processing: mysql-server-5.7 mysql-server E: Sub-process /usr/bin/dpkg returned an error code (1)

malikarumi@Tetuoan2:~$ sudo dpkg --audit The following packages have been unpacked but not yet configured. They must be configured using dpkg --configure or the configure menu option in dselect for them to work: mysql-server MySQL database server (metapackage depending on the lates

The following packages are only half configured, probably due to problems configuring them the first time. The configuration should be retried using dpkg --configure <package> or the configure menu option in dselect: mysql-server-5.7 MySQL database server binaries and system database setup

malikarumi@Tetuoan2:~$ sudo dpkg -C The following packages have been unpacked but not yet configured. They must be configured using dpkg --configure or the configure menu option in dselect for them to work: mysql-server MySQL database server (metapackage depending on the lates

The following packages are only half configured, probably due to problems configuring them the first time. The configuration should be retried using dpkg --configure <package> or the configure menu option in dselect: mysql-server-5.7 MySQL database server binaries and system database setup

malikarumi@Tetuoan2:~$ sudo dpkg --configure dpkg: error: --configure 需要至少一个包名称参数

输入 dpkg --help 获取有关安装和卸载软件包的帮助 [*];使用 'apt' 或 'aptitude' 进行用户友好的包管理;键入 dpkg -Dhelp 以获取 dpkg 调试标志值列表;输入 dpkg --force-help 以获取强制选项列表;输入 dpkg-deb --help 获取有关操作 *.deb 文件的帮助;

标记为 [*] 的选项会产生大量输出 - 通过“less”或“more”进行管道传输! malikarumi@Tetuoan2:~$

我可以看到输出中已经有 --configure 错误,所以我没有运行它。

与其他 unix 交换问题中的操作不同,我没有(故意)混合操作系统,并且在其他方​​面我的操作系统似乎很好,所以我没有尝试他的解决方案。正是在这个时候,我来到这里发帖。建议?

答案1

好吧,正如你所说,删除所有内容并重新开始是好的。首先,确保您仅使用默认软件存储库,并执行apt-get update.

以下是我如何设置本地工作站开发(Mint,但 Mint=Ubuntu)。请注意,这是非常非常不安全的,我这样做的方式除了localhost仅使用之外,您必须防火墙关闭服务或仅将它们绑定到您的环回适配器。

首先,安装mysql。您需要确保完全清除了以前的版本,或者记住设置的任何 root 密码。在 Mint 19/Ubuntu 18.04 上,当使用套接字而不是网络时,匹配的用户名会自动进行身份验证并忽略密码 - 请注意这一点,这让我在全新安装时感到痛苦和咬牙切齿。

反正,apt-get install mysql-server mysql-client。在某些时候,我进去并为其创建一个基本数据库和用户(通常名为“lampdev”),但这是在安装后完成的......

接下来是apache和php以及php+mysql的支持——

apt-get install apache2 libapache2-mod-php php-mysql

我也倾向于同时使用两者phpmyadminmysql-workbench因此它们也都被安装了。

这里是安全性最南端的地方 -

然后我添加一个组 - webdev- 并将我的用户帐户和www-data用户添加到其中,以及( ) 和chown -R .webdev它。 DocumentRoot/var/www/htmlchmod g+s

相关内容