MySQL 安装过程中踩过的坑

1、用 grep 'temporary password' /var/log/mysqld.log 生成的初始密码老提示密码错误,只能直接发大招:

        A、vi /etc/my.cnf 在文件的 [mysqld] 内增加一行  skip_table_grant_tables

        B、 重启mysql:   systemctl restart mysqld.service

        C、无密码登录mysql:   mysql -uroot

        D、执行: flush privileges; (注:如未执行,后续的 alter user 更新密码会报:The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement)
        E、更新用户密码: alter user 'root'@'localhost' identified by '123456';  (注:此处密码是123456)

             (MySQL的默认密码规则比较复杂,可执行:set global validate_password.length=6 等操作修改设置值,以降低复杂度)

        F、执行: flush privileges; 并退出 mysql

        G、vi /etc/my.cnf 在文件的 [mysqld] 内取消  skip_table_grant_tables

        H、重启mysql: systemctl restart mysqld.service

2、Linux系统上的MySQL默认表名、列名大小敏感,不能按网上说的直接在  /etc/my.cnf 内设置 lower_case_table_names=1, 会导致MySQL无法启动。

3、安装后无法远程连接。一般是以下两个原因导致:

      A、mysql的登录用户主机是本地,可通过  update user set Host='%' where User = '登录名',  修改

      B、检查服务器防火墙的3306端口是否开启,如未开启,则打开。对应操作命令如下:

             1)   查询端口状态: firewall-cmd --query-port=3306/tcp

             2)  查询防火墙状态:  service firewalld status

             3)  设置端口开启:   firewall-cmd --permanent --zone=public --add-port=3306/tcp 

                                               firewall-cmd --reload

 

      C、reboot 重启服务器

 

posted @ 2023-03-07 09:33  千年海岩  阅读(10)  评论(0编辑  收藏  举报