Linux本地部署Mysql服务

一、校验安装历史

1、查看是否已安装mysql

rpm -qa | grep mysql

2、 如果已安装,则删除

rpm -e --nodeps mysql-community-release-el7-7.noarch

二、下载并安装Mysql

1、下载8.0版本的mysql

wget http://repo.mysql.com/mysql80-community-release-el7-7.noarch.rpm

 2、安装rpm包

rpm -ivh mysql80-community-release-el7-7.noarch.rpm

3、更新插件版本

yum -y update

 4、安装mysql服务端

yum -y install mysql-server

5、 配置权限

chown -R mysql:mysql /var/lib/mysql/

 6、初始化mysql

mysqld --initialize

 7、启动mysql

systemctl start mysqld

 8、查看mysql状态

systemctl status mysqld

 注:mysql会自动生成一个默认密码在日志文件中

#查看mysql日志:cat /var/log/mysqld.log

[Server] A temporary password is generated for root@localhost: B>iCWF#Ff5Vl

 9、Mysql升级问题

mysql5.7升级到8.0如果报错
2023-03-09T00:43:22.731223Z 1 [ERROR] [MY-013856] [InnoDB] The redo log file ./ib_logfile0 is empty, which indicates it was not generated by InnoDB or become corrupted. Please restore the correct file or try recovering without the redo files, in read-only mode, by providing --innodb-force-recovery=6.
2023-03-09T00:43:22.731284Z 1 [ERROR] [MY-012930] [InnoDB] Plugin initialization aborted with error Generic error.
2023-03-09T00:43:23.170973Z 1 [ERROR] [MY-011013] [Server] Failed to initialize DD Storage Engine.
2023-03-09T00:43:23.171331Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2023-03-09T00:43:23.171370Z 0 [ERROR] [MY-010119] [Server] Aborting

 解决方式:

执行命令:rm -rf /var/lib/mysql,再重启mysql服务可完成:systemctl start mysql

三、修改密码

1、进入mysql内部

mysql -uroot -p

2、查询root账户的host

use mysql;
select user,host from user;

3、修改密码

host为步骤二查询出来的root账户的host

alter user 'root'@'host' identified with mysql_native_password by '新密码';

4、刷新内存

flush privileges;

5、重启mysql

systemctl restart mysql;

四、Navicat连接

修改root账户的host为‘%’即可。

update user set host = '%' where user = 'root';

如果navicat还连接不上,则进入mysql的配置文件进行修改,将bind_address = 127.0.0.1注掉或删除,重启mysql服务(systemctl restart mysql

vim /etc/mysql/mysql.conf.d/mysqld.cnf

五、开放防火墙端口

#查看是否开启端口
firewall-cmd --list-all
#开启端口3306
firewall-cmd --zone=public --add-port=3306/tcp --permanent
#重新加载防火墙
firewall-cmd --reload

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值