当前位置: 首页 > news >正文

作为一个大学生网站 应该怎么做有链接的网站

作为一个大学生网站 应该怎么做,有链接的网站,免费bi软件,网站建设120本文主要总结Linux安装Mysql后,其他主机访问不了MySQL数据库的原因和解决方法 环境说明: MySQL 5.7.30CentOS Linux release 7.6.1810 (Core) 创建完Mysql数据库后可以查看mysql 日志获取root 用户登录密码 [rootlocalhost mysql-5.7.30]# cat /var/l…


本文主要总结Linux安装Mysql后,其他主机访问不了MySQL数据库的原因和解决方法

环境说明:

  • MySQL 5.7.30
  • CentOS Linux release 7.6.1810 (Core)

创建完Mysql数据库后可以查看mysql 日志获取root 用户登录密码

[root@localhost mysql-5.7.30]# cat /var/log/mysqld.log

 使用获取到的密码就可以登录数据库了,登录后显示mysql> 表示成功

[root@localhost etc]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.30Copyright (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> 
mysql> 

登录后root用户不能直接使用,会提示需要先重置密码,重置密码的时候可能会出现not stifsy current plicy错误。 默认情况下密码长度是8位, 如果希望密码简单好记,需要修改规则

mysql> set password for root@localhost=password("root");
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> 
mysql> set global validate_password_length=4;
Query OK, 0 rows affected (0.00 sec)mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)mysql> set password for root@localhost=password("root");
Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)mysql> use mysql;
Database changed
mysql> 

此时如果使用Navicat链接Mysql数据库是链接不上的,

 Mysql数据库系统中,每一用户都有自己的用户名和密码, 同时还有自己的主机名称,root用户默认的主机名称是 localhost, 所以只能localhost方法, 不能使用其他主机访问。  如果此时需要设置root用户其他主机也可以访问,修改后使用flush privileges 刷新权限,这样不用重启。 

mysql> grant all privileges on *.* to 'root'@'%' identified by 'root';
Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)mysql> 
mysql> select user ,host from user;
+---------------+-------------+
| user          | host        |
+---------------+-------------+
| root          | %           |
| mysql.session | localhost   |
| mysql.sys     | localhost   |
| root          | localhost   |
+---------------+-------------+
4 rows in set (0.00 sec)mysql> 

此时使用IP访问也可能不成功,部分人可能访问数据库成功, 部分人可能访问数据库库失败。 如果访问链接失败, 再查看my.cnf或者my.ini的配置, 查找bind-address参数。将其注释或者修改为0.0.0.0或者服务器的IP地址。如果没有可以手写此配置

[root@localhost ~]# cd /etc
[root@localhost etc]# 
[root@localhost etc]# ls
adjtime                  ethertypes          ld.so.cache               plymouth        
crypttab                 hostname            my.cnf                    resolv.conf     tuned
csh.cshrc                hosts               my.cnf.d                  rpc             udev
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
bind-address=0.0.0.0# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

 到此又会有部分人访问数据库成功, 部分人访问数据库仍然失败, 如果还是悲剧的这部分人,还需要查看防火墙设置,Linux系统中,防火墙iptables可能会阻止MySQL的外部访问。使用下面的命令查看


[root@localhost etc]# sudo iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:cslistener
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED......略

 此时列表中如果没有mysql 信息,那么可以执行下面的命令允许外部访问Myslq, 其中dport 指定3306, 3306是MySQL的默认端口。执行后再使用sudo iptables -L查看会出现mysql访问信息。如下

[root@localhost etc]# sudo  iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
[root@localhost etc]# 
[root@localhost etc]# sudo iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:mysql
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:cslistener
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED......略

最后重启MySQL后就可以访问MySQL数据库了

 上一篇:Linux 安装MySQL-5.7.30

http://www.wangmingla.cn/news/767.html

相关文章:

  • 公司网站功能模块句容市网站seo优化排名
  • 做网站要不要交税百度广告推广怎么做
  • 网络架构是什么西安做推广优化的公司
  • 郑州做网站公司+卓美百度网盟推广
  • 做暖暖视频网站app推广拉新渠道
  • 网站咋建立短链接在线生成免费
  • 网站建设的意义百度关键词推广一年多少钱
  • ps做购物小网站独立站seo
  • .com网站备案网络优化器下载
  • 哪家上市公司做视频网站网络推广方案怎么写
  • 做销售平台哪个网站好搜索引擎优化论文3000字
  • 查看网站点击量个人如何做百度推广
  • 国内做的比较好的网站网站统计
  • 专门做娱乐场所的设计网站免费十八种禁用网站
  • 论坛类网站可以做移动端吗有必要买优化大师会员吗
  • 自助网站制作爱站网站排名查询工具
  • 高端大气上档次的网站软文营销推广
  • wordpress评论可见插件seo入门教程网盘
  • 沧州网络运营公司seo网站推广实例
  • 如何判断网站好坏培训机构是干什么的
  • c做项目的网站一键识图找原图
  • 四六级查成绩网站怎么做国际新闻直播
  • 微网站平台微网站建设方案常用的seo查询工具有哪些
  • 做网站平台成本宁德市旅游景点大全
  • 政府网站模板php网址查询工具
  • java php 大型网站开发河南企业网站推广
  • 做标签网站是什么重庆seo网站建设
  • 原有网站已备案 怎么做接入pc网站优化排名软件
  • 上海建设银行青浦分行网站全网关键词云查询
  • 医院网站建设需求分析调研表列表网推广效果怎么样