Centos7安装mysql笔记

Centos7安装mysql笔记


最近搬家了WiFi网络发生变化,centos需要重新连接WiFi特此记录一下连接命令与mysql安装。

WiFi连接

wpa_supplicant -B -i wlp3s0 -c <(wpa_passphrase “用户名” “密码”);
dhclient wlp3s0;
systemctl start network.service;

安装mysql

  • 下载
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
  • 安装rpm
yum localinstall mysql57-community-release-el7-8.noarch.rpm
  • 检查
yum repolist enabled | grep "mysql.*-community.*"
  • 安装社区版mysql
yum install mysql-community-server
  • 服务启动
systemctl start mysqld
  • 查找mysql默认密码
grep 'temporary password' /var/log/mysqld.log
  • 输出

2020-04-01T06:04:30.472082Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: TuOoxF;Ug6_q

登陆失败解决

vi /etc/my.cnf 在最后一行加skip-grant-tables保存重启mysql

systemctl restart mysqld

登陆mysql一路回车无需密码

mysql -uroot -p
登录后
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set authentication_string="" where user="root";
Query OK, 1 row affected (0.12 sec)
Rows matched: 1  Changed: 1  Warnings: 0

删除刚才加入的skip-grant-tables在/etc/my.cnf 文件中,然后重启mysql,一路回车登陆。

[root@bogon /home/wanbao]$ vi /etc/my.cnf
[root@bogon /home/wanbao]$ systemctl restart mysqld
[root@bogon /home/wanbao]$ mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.19

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

修改密码,并刷新缓存,下次登陆就需要输入密码登录

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '自己的密码' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.43 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.34 sec)

  • 设置远程登陆
mysql> update user set host='%';
Query OK, 3 rows affected (0.37 sec)
Rows matched: 4  Changed: 3  Warnings: 0

mysql> select  User,authentication_string,Host from user;
+------------------+------------------------------------------------------------------------+------+
| User             | authentication_string                                                  | Host |
+------------------+------------------------------------------------------------------------+------+
| mysql.infoschema | $A$005$ERFFFFSSCC| %    |
| mysql.session    | $A$005$ $A$005$ERFFFFSSCC| %    |
| mysql.sys        | $A$005$ $A$005$ERFFFFSSCC| %    |
| root             | $A$005$* -A$005$ERFFFFSSCC| %    |
+------------------+------------------------------------------------------------------------+------+
4 rows in set (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.62 sec)

退出mysql发现还是登录不了,查看3306端口,外部并不能访问

netstat -an|grep 3306

打开对外访问权限,这个简单的问题搞了一晚上终于找到解决方案

firewall-cmd --add-port=3306/tcp

终于大功告成,外部可以访问了。
workbench

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值