微服务架构项目搭建过程中的Mysql安装和相关问题

搭建微服务架构的过程中需要使用Mysql数据库,Mysql数据库搭建着实不是一个容易的事情,会碰到各种各样的问题,如果没有一个安装数据库的思路真的很难把数据库安装好,并且掉入到安装的坑当中而无法自拔,因为数据库版本与微服务架构中初始化数据的数据库版本不匹配导致反复安装折腾了一个周,所以把安装思路和遇到的问题跟大家分享一下

数据库安装时一定要确认的问题就是 数据库安装的版本,在工作中一般这一块都会去确认,安装文档应该也会有说明,如果没有说明,记得一定要去确认一下,因为涉及到安装完成后的数据库初始化操作,一般数据库初始脚本与数据库都会进行匹配,本文以下载Mysql5.7为例

数据库安装前为了避免出现各种奇葩的问题,先进行依赖的安装最好都安装完成

yum install libaio libaio-devel numactl-libs wget vim -y

yum这里简单说一下yum。在Linux的学习或者使用过程中应该对yum都有一定的了解

yum是软件仓库,repo文件是Linux中yum的配置文件,定义了软件仓库的细节例如从哪里下载软件包等内容

Exp:在进行安装Mysql报错Cannot find a valid baseurl for repo:base就是由于repo源不对导致

# 下载安装包function1:使用wget命令从官网下载
wget http://dev.mysql.com/get/mysql-5.7.26-1.el7.x86_64.rpm-bundle.tartar -xvf mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar

function2:从官网下载上传至服务器

rpm -ivh mysql-community-common-5.7.26-1.el7.x86_64.rpm​rpm -ivh mysql-community-libs-5.7.26-1.el7.x86_64.rpm​rpm -ivh mysql-community-client-5.7.26-1.el7.x86_64.rpm​rpm -ivh mysql-community-server-5.7.26-1.el7.x86_64.rpm
systemctl start mysqld.service

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

step1: mysql> alter user 'root'@'localhost' identified by '123456';

ERROR 1203 (42000): User dba already has more than ‘max_user_connections’ active connections。

1.vim /etc/my.cnf//在[mysqld]下添加max_connections=10000​2.重启mysql服务[root@localhost ]:systemctl restart mysqld.service​3.查询最大连接数mysql> show variables like "max_connections";

输入正确的用户名和密码登录报错:ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)

1.停止mysql数据库systemctl restart mysqld.service(或直接 kill -9 [PID]  杀进程!)2.执行如下命令mysqld_safe --user=mysql --skip-grant-tables --skip-networking &3.使用root登录mysql数据库mysql -u root mysql4.更新root密码mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';5.刷新权限mysql> FLUSH PRIVILEGES;6.退出mysqlmysql> quit​7.重启mysql[root@localhost ]:systemctl restart mysqld.service​8.使用root用户重新登录mysqlmysql -uroot -p Enter password:

报错:null, message from server: “Host ‘117.89.209.18’ is not allowed to connect to this MySQL server”这是因为你的帐号不允许从远程登陆,只能在服务器所在的机器才可以。这个时候只要在localhost的那台电脑改为%,任何机器都可以访问都可以即可

mysql>use mysql;mysql>update user set host = '%' where user = 'root';

这种情况不多见,一般是操作过多没记住,但是在navicat有保存就可以找到

1.导出连接a.选择想要获取密码的数据库即可b.拿到保存到本地的connections.ncx文件中的Password2.解密passworda.登陆https://tool.lu/coderunner,使用PHP在线运行工具

粘贴如下代码

class NavicatPassword
{
protected $version = 0;
protected $aesKey = 'libcckeylibcckey';
protected $aesIv = 'libcciv libcciv ';
protected $blowString = '3DC5CA39';
protected $blowKey = null;
protected $blowIv = null;

public function __construct($version = 12)
{
$this->version = $version;
$this->blowKey = sha1('3DC5CA39', true);
$this->blowIv = hex2bin('d9c7c3c8870d64bd');
}

public function encrypt($string)
{
$result = FALSE;
switch ($this->version) {
case 11:
$result = $this->encryptEleven($string);
break;
case 12:
$result = $this->encryptTwelve($string);
break;
default:
break;
}

return $result;
}

protected function encryptEleven($string)
{
$round = intval(floor(strlen($string) / 8));
$leftLength = strlen($string) % 8;
$result = '';
$currentVector = $this->blowIv;

for ($i = 0; $i < $round; $i++) {
$temp = $this->encryptBlock($this->xorBytes(substr($string, 8 * $i, 8), $currentVector));
$currentVector = $this->xorBytes($currentVector, $temp);
$result .= $temp;
}

if ($leftLength) {
$currentVector = $this->encryptBlock($currentVector);
$result .= $this->xorBytes(substr($string, 8 * $i, $leftLength), $currentVector);
}

return strtoupper(bin2hex($result));
}

protected function encryptBlock($block)
{
return openssl_encrypt($block, 'BF-ECB', $this->blowKey, OPENSSL_RAW_DATA|OPENSSL_NO_PADDING);
}

protected function decryptBlock($block)
{
return openssl_decrypt($block, 'BF-ECB', $this->blowKey, OPENSSL_RAW_DATA|OPENSSL_NO_PADDING);
}

protected function xorBytes($str1, $str2)
{
$result = '';
for ($i = 0; $i < strlen($str1); $i++) {
$result .= chr(ord($str1[$i]) ^ ord($str2[$i]));
}

return $result;
}

protected function encryptTwelve($string)
{
$result = openssl_encrypt($string, 'AES-128-CBC', $this->aesKey, OPENSSL_RAW_DATA, $this->aesIv);
return strtoupper(bin2hex($result));
}

public function decrypt($string)
{
$result = FALSE;
switch ($this->version) {
case 11:
$result = $this->decryptEleven($string);
break;
case 12:
$result = $this->decryptTwelve($string);
break;
default:
break;
}

return $result;
}

protected function decryptEleven($upperString)
{
$string = hex2bin(strtolower($upperString));

$round = intval(floor(strlen($string) / 8));
$leftLength = strlen($string) % 8;
$result = '';
$currentVector = $this->blowIv;

for ($i = 0; $i < $round; $i++) {
$encryptedBlock = substr($string, 8 * $i, 8);
$temp = $this->xorBytes($this->decryptBlock($encryptedBlock), $currentVector);
$currentVector = $this->xorBytes($currentVector, $encryptedBlock);
$result .= $temp;
}

if ($leftLength) {
$currentVector = $this->encryptBlock($currentVector);
$result .= $this->xorBytes(substr($string, 8 * $i, $leftLength), $currentVector);
}

return $result;
}

protected function decryptTwelve($upperString)
{
$string = hex2bin(strtolower($upperString));
return openssl_decrypt($string, 'AES-128-CBC', $this->aesKey, OPENSSL_RAW_DATA, $this->aesIv);
}
};
//需要指定版本两种,11或12
//$navicatPassword = new NavicatPassword(11);
$navicatPassword = new NavicatPassword(11);

//解密
//$decode = $navicatPassword->decrypt('15057D7BA390');
$decode = $navicatPassword->decrypt('15057D7BA390');
echo $decode."\n";
?>
用文件中的文件中的password,替换上面代码中的$decode = $navicatPassword->decrypt('E75BF077AB8BAA3AC2D5');点击运行之后,就会得到真实密码

Original: https://www.cnblogs.com/Skywal/p/15880237.html
Author: 天行者_sky
Title: 微服务架构项目搭建过程中的Mysql安装和相关问题

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/613001/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球