受欢迎的唐山网站建设,h5自己制作模板,福田网站建设效果,四川建设信息网文章目录 下载 MySQL yum包安装MySQL源安装MySQL服务端,需要等待一些时间启动MySQL修改密码方式一#xff1a;临时密码获取临时密码#xff0c;MySQL5.7为root用户随机生成了一个密码通过临时密码登录MySQL#xff0c;进行修改密码操作 方式二#xff1a;skip-grant-tables… 文章目录 下载 MySQL yum包安装MySQL源安装MySQL服务端,需要等待一些时间启动MySQL修改密码方式一临时密码获取临时密码MySQL5.7为root用户随机生成了一个密码通过临时密码登录MySQL进行修改密码操作 方式二skip-grant-tables1修改/etc/my.cnf在 [mysqld] 小节下添加一行重启mysqld 服务使用 root 用户登录到 mysql切换到mysql数据库更新 user 表删除 skip-grant-tables1 授权其他机器远程登录开启开机自启动更改默认端口常见操作 下载 MySQL yum包
wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm安装MySQL源
rpm -Uvh mysql57-community-release-el7-10.noarch.rpm安装MySQL服务端,需要等待一些时间
yum install -y mysql-community-server如果提示 The GPG keys listed for the “MySQL 5.7 Community Server” repository are already installed but they are not correct for this package. Check that the correct key URLs are configured for this repository. Failing package is: mysql-community-libs-compat-5.7.37-1.el7.x86_64 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql 原因是Mysql的GPG升级了需要重新获取使用以下命令即可
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022启动MySQL
systemctl start mysqld.service检查是否启动成功:
systemctl status mysqld.service修改密码
方式一临时密码
获取临时密码MySQL5.7为root用户随机生成了一个密码
grep temporary password /var/log/mysqld.log 通过临时密码登录MySQL进行修改密码操作
使用临时密码登录后不能进行其他的操作否则会报错这时候我们进行修改密码操作
mysql -uroot -pALTER USER rootlocalhost IDENTIFIED BY yourpassword;方式二skip-grant-tables1
修改/etc/my.cnf在 [mysqld] 小节下添加一行 skip-grant-tables1 这一行配置让 mysqld 启动时不对密码进行验证
重启mysqld 服务
systemctl restart mysqld使用 root 用户登录到 mysql
mysql -uroot 切换到mysql数据库更新 user 表
use mysql
update user set authentication_string password(123456),password_expired N, password_last_changed now() where user root;在之前的版本中密码字段的字段名是 password5.7版本改为了 authentication_string
删除 skip-grant-tables1
退出 mysql编辑 /etc/my.cnf 文件删除 skip-grant-tables1的内容
授权其他机器远程登录
GRANT ALL PRIVILEGES ON *.* TO root% IDENTIFIED BY yourpassword WITH GRANT OPTION;FLUSH PRIVILEGES;vim /etc/my.cnf开启开机自启动
systemctl enable mysqld
systemctl daemon-reload更改默认端口
修改/etc/my.cnf在 [mysqld] 小节下添加一行
port你想要的端口号重启mysqld 服务
systemctl restart mysqld常见操作
查看mysql是否启动service mysqld status启动mysqlservice mysqld start停止mysqlservice mysqld stop重启mysqlservice mysqld restart