关于 MySQL 8 有 3 个大坑:
1. 启动 MySQL 会报错,提示未找到 /var/run/mariadb/mariadb.pid,但是我们只需要 mkdir /var/run/mariadb,而不需要 touch /var/run/mariadb/mariadb.pid。
2. MySQL 客户端已经附带,位于 /usr/local/mysql/bin/mysql,不需要通过 yum 安装。
3. 在 PHP 测试代码中,mysqli_connect() 函数的第一个参数必须使用 127.0.0.1,而不能使用 localhost。
1. 启动 MySQL 会报错,提示未找到 /var/run/mariadb/mariadb.pid,但是我们只需要 mkdir /var/run/mariadb,而不需要 touch /var/run/mariadb/mariadb.pid。
2. MySQL 客户端已经附带,位于 /usr/local/mysql/bin/mysql,不需要通过 yum 安装。
3. 在 PHP 测试代码中,mysqli_connect() 函数的第一个参数必须使用 127.0.0.1,而不能使用 localhost。
2019-11-04
vim /usr/local/nginx/html/db.php
<?php
$link = mysqli_connect('127.0.0.1', 'root', '密码');
if ($link)
{
var_dump($link);
}
else
{
$error = mysqli_connect_error();
var_dump($error);
}
<?php
$link = mysqli_connect('127.0.0.1', 'root', '密码');
if ($link)
{
var_dump($link);
}
else
{
$error = mysqli_connect_error();
var_dump($error);
}
2019-11-04
参考:https://dev.mysql.com/doc/refman/8.0/en/binary-installation.html
yum install libaio perl numactl
yum install libaio perl numactl
2019-11-04
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz
下载地址来自 https://dev.mysql.com/downloads/mysql/
tar -Jxvf mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz -C /opt/
mv /opt/mysql-8.0.18-linux-glibc2.12-x86_64 /opt/mysql
ln -s /opt/mysql /usr/local/mysql
下载地址来自 https://dev.mysql.com/downloads/mysql/
tar -Jxvf mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz -C /opt/
mv /opt/mysql-8.0.18-linux-glibc2.12-x86_64 /opt/mysql
ln -s /opt/mysql /usr/local/mysql
2019-11-04
useradd -r -s /bin/false mysql
mkdir /usr/local/mysql/mysql-files
chown mysql:mysql /usr/local/mysql/mysql-files
chmod 750 /usr/local/mysql/mysql-files
/usr/local/mysql/bin/mysqld --initialize --user=mysql
执行结果中包含临时密码
mkdir /usr/local/mysql/mysql-files
chown mysql:mysql /usr/local/mysql/mysql-files
chmod 750 /usr/local/mysql/mysql-files
/usr/local/mysql/bin/mysqld --initialize --user=mysql
执行结果中包含临时密码
2019-11-04
/usr/local/mysql/bin/mysql_ssl_rsa_setup
mkdir /var/log/mariadb
touch /var/log/mariadb/mariadb.log
chown mysql:mysql /var/log/mariadb/mariadb.log
mkdir /var/run/mariadb
chown mysql:mysql /var/run/mariadb
/usr/local/mysql/bin/mysqld_safe --user=mysql &
mkdir /var/log/mariadb
touch /var/log/mariadb/mariadb.log
chown mysql:mysql /var/log/mariadb/mariadb.log
mkdir /var/run/mariadb
chown mysql:mysql /var/run/mariadb
/usr/local/mysql/bin/mysqld_safe --user=mysql &
2019-11-04
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql.server
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
/usr/local/mysql/bin/mysql -u root -p
临时密码
mysql> ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘密码’;
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
/usr/local/mysql/bin/mysql -u root -p
临时密码
mysql> ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘密码’;
2019-11-04
关于 PHP 配置文件的补充:
1. cp /usr/local/etc/php-fpm.conf.default /usr/local/etc/php-fpm.conf
2. vim /usr/local/etc/php-fpm.conf
最后一行修改为:include=etc/php-fpm.d/*.conf
1. cp /usr/local/etc/php-fpm.conf.default /usr/local/etc/php-fpm.conf
2. vim /usr/local/etc/php-fpm.conf
最后一行修改为:include=etc/php-fpm.d/*.conf
2019-11-03