MySQL 数据库需要几个下载和准备步骤。一般情况下,我们需要 root 访问权限和 SSH 服务器访问知识。由于本文涵盖了一些有关 MySQL 安装和设置的基本教程,主要记录了我在CentOS系统中踩下的坑。
常见mysql服务命令
systemctl start mysqld # 开启mysql服务
systemctl stop mysqld # 关闭mysql服务
systemctl restart mysqld # 重启mysql服务
systemctl status mysqld # 查看mysql服务的状态
Step1 安装Mysql
下载安装Mysql Yum 仓库
wget https://repo.mysql.com/mysql80-community-release-el7-1.noarch.rpm
yum localinstall mysql80-community-release-el7-1.noarch.rpm
安装Mysql 社区
yum install mysql-community-server -y
Step2 遇到公钥对不上的问题
问题如下:
The GPG keys listed for the "ysQL 8.0 Community Server'' repository are already installed [Fix]
解决方式:
(1)To fix this error, import the new GPG key for MySQL.
# rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
(2)Once the new key is imported, update the packages.
# yum update
Step3 如何寻找密码
mysql在安装过程中会自动生成一个临时密码,通过如下命令来提取
sudo grep 'password' /var/log/mysqld.log
这里会输出
[Note] A temporary password is generated for root@localhost: Liaka*(Dka&^Kjs
Step4 登录并重置密码
# 启动
systemctl start mysql
mysql -u root -p
# 重置
alter user 'root'@'localhost' identified by '@YourNewPassword';
参考文章
- https://www.sjkjc.com/mysql/install-on-centos/
- https://www.51cto.com/article/741252.html
- https://techglimpse.com/gpg-keys-mysql-not-correct-centos/

3981

被折叠的 条评论
为什么被折叠?



