前言:
如今看官们对“mysql怎么重启”大概比较注意,姐妹们都需要知道一些“mysql怎么重启”的相关文章。那么小编也在网摘上收集了一些有关“mysql怎么重启””的相关文章,希望小伙伴们能喜欢,兄弟们一起来了解一下吧!下载链接
MySQL安装前置准备# 检查是否存在MariaDBrpm -qa | grep mariadb# 删除现存MariaDByum -y remove mariadb*# 检查是否存在MySQLrpm -qa | grep mysql# 删除现存MySQLyum -y remove mysql*# 删除旧配置文件rm -rf /etc/my.cnf# 删除MySQL相关文件rm -rf /var/lib/mysql安装MySQL
# 配置安装源sudo rpm -Uvh rpm -Uvh 更新MySQL公钥rpm --import 安装MySQL,以防万一增加--nogpgcheck参数,跳过公钥安装sudo yum --enablerepo=mysql80-community install -y mysql-community-server --nogpgcheck启动MySQL
# 启动MySQLsystemctl start mysqld.service# 检查运行状态systemctl status mysqld.service# 设置MySQL为开机自启动systemctl enable mysqld.service# 查看端口运行情况netstat -nlpt# 停止MySQLsystemctl stop mysqld# 重启MySQLsystemctl restart mysqldMySQL 初始化设置
# 查看默认密码cat /var/log/mysqld.log | grep localhostcat /var/log/mysql/mysqld.log | grep localhost# 登录MySQL Shellmysql -uroot -p# 修改MySQL密码 (密码为P@ssw0rd)ALTER USER USER() IDENTIFIED BY 'P@ssw0rd';# 检查系统用户访问权限use mysql;select user,host,plugin,authentication_string from mysql.user;select user,host,plugin from mysql.user;# 开启 root 远程登录权限,并刷新update mysql.user set host='%' where user='root';flush privileges;# 退出MySQL Shellexit使用初始化向导配置MySQL
# 查看默认密码cat /var/log/mysqld.log# 数据库初始化向导sudo mysql_secure_installation# 确保MySQL服务器部署的安全。输入用户root的密码:Securing the MySQL server deployment.Enter password for user root: # 用户帐户根的现有密码已过期。请设置新密码。The existing password for the user account root has expired. Please set a new password.# 新密码:New password: # 重新输入新密码Re-enter new password: # 是否更换root密码 NChange the password for root ? ((Press y|Y for Yes, any other key for No) # 是否删除匿名用户 YRemove anonymous users? (Press y|Y for Yes, any other key for No) :# 是否禁止root用户远程登录 NDisallow root login remotely? (Press y|Y for Yes, any other key for No) :# 是否删除test数据库 YRemove test database and access to it? (Press y|Y for Yes, any other key for No) :# 是否重新加载权限表 YReload privilege tables now? (Press y|Y for Yes, any other key for No) :测试MySQL
# 进入MySQL Shellsudo mysql -uroot -pP@ssw0rd# 测试MySQL,刷新权限flush privileges;# 测试MySQL,列出数据库show databases;# 测试MySQL,查看用户select user,host from mysql.user;# 退出MySQL Shellexit修改MySQL密码加密方式
# 修改root用户密码加密方式为mysql_native_password 并修改密码ALTER USER `root`@`%` IDENTIFIED WITH mysql_native_password BY 'P@ssw0rd';ALTER USER `keystone`@`%` IDENTIFIED WITH mysql_native_password;取消非root用户登录MySQL的root用户限制
# 进入MySQL Shellsudo mysql -uroot -pP@ssw0rd# 取消非root用户登录MySQL的root用户限制ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'P@ssw0rd';update user set host='%' where user='root';Grant all privileges on test.* to 'root'@'%';alter user root identified with mysql_native_password by 'P@ssw0rd';Grant all privileges on root.* to 'root'@'%';
版权声明:
本站文章均来自互联网搜集,如有侵犯您的权益,请联系我们删除,谢谢。
标签: #mysql怎么重启