• centos7 mysql5.7离线安装


    1.下载mysql

    https://pan.baidu.com/s/1Dld4cpo2h_dECTMusMLfUg   提取码:lmkh

    2.查看并删除机器中 mariadb

    1. rpm -qa | grep mariadb
    2. rpm -qa | grep mariadb |xargs yum remove -y

    3.查找并删除mysql残留文件

    1. find / -name mysql
    2. rm -rf /var/lib/mysql
    3. rm -rf /var/log/mysqld.log
    4. rm -rf /var/log/mysql.log

    4. mysql-5.7.30-1.el7.x86_64.rpm.tar上传解压

    tar -xvf mysql-5.7.30-1.el7.x86_64.rpm.tar

    5.依次安装解压后的RPM包(注:必须按顺序依次安装,否则会因缺少依赖安装失败)

    1. rpm -ivh mysql-community-common-5.7.30-1.el7.x86_64.rpm
    2. rpm -ivh mysql-community-libs-5.7.30-1.el7.x86_64.rpm
    3. rpm -ivh mysql-community-devel-5.7.30-1.el7.x86_64.rpm
    4. rpm -ivh mysql-community-libs-compat-5.7.30-1.el7.x86_64.rpm
    5. rpm -ivh mysql-community-client-5.7.30-1.el7.x86_64.rpm
    6. rpm -ivh mysql-community-server-5.7.30-1.el7.x86_64.rpm

    6.修改mysql配置文件 ,根据自己需求 编辑 /etc/my.cnf 文件 

    ps 注意自定义存储路径和日志路径,要更改自定义目录的所属用户和读写权限

    1. # For advice on how to change settings please see
    2. # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
    3. [mysqld]
    4. #
    5. # Remove leading # and set to the amount of RAM for the most important data
    6. # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
    7. # innodb_buffer_pool_size = 128M
    8. #
    9. # Remove leading # to turn on a very important data integrity option: logging
    10. # changes to the binary log between backups.
    11. # log_bin
    12. #
    13. # Remove leading # to set options mainly useful for reporting servers.
    14. # The server defaults are faster for transactions and fast SELECTs.
    15. # Adjust sizes as needed, experiment to find the optimal values.
    16. # join_buffer_size = 128M
    17. # sort_buffer_size = 2M
    18. # read_rnd_buffer_size = 2M
    19. datadir=/data/mysql/data
    20. socket=/data/mysql/data/mysql.sock
    21. # Disabling symbolic-links is recommended to prevent assorted security risks
    22. symbolic-links=0
    23. log-error=/data/mysql/log/mysqld.log
    24. pid-file=/var/run/mysqld/mysqld.pid
    25. [client]
    26. port=3306
    27. socket=/data/mysql/data/mysql.sock
    1. chown -R mysql:mysql /data/mysql
    2. chmod -R 777 /data/mysql

    7.修改mysql配置后,如果更改mysql数据的默认存储地址,需要重新初始化更改后的目录

    mysqld  --initialize

    8.启动mysql

    systemctl start mysqld.service

    9 查看mysql运行状态

    systemctl status mysqld

    10 查看mysql启动日志,获得root用户的默认密码

    tail -f -n 200 /data/mysql/log/mysqld.log
    1. 2022-09-21T02:00:26.402396Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option
    2. (see documentation for more details).
    3. 2022-09-21T02:00:26.620666Z 0 [Warning] InnoDB: New log files created, LSN=45790
    4. 2022-09-21T02:00:26.658043Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
    5. 2022-09-21T02:00:26.715686Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Ge
    6. nerating a new UUID: 29588cde-3951-11ed-8d10-286ed48993c2.
    7. 2022-09-21T02:00:26.717087Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
    8. 2022-09-21T02:00:27.410586Z 0 [Warning] CA certificate ca.pem is self signed.
    9. 2022-09-21T02:00:27.742405Z 1 [Note] A temporary password is generated for root@localhost: xxxxxxxxx

    11.设置Mysql 开机自启动

    sudo systemctl enable mysqld

    12 从日志文件中查询root用户默认密码,连接mysql,第一次连接需要更改root用户密码。

    grep 'temporary password' /data/mysql/log/mysqld.log
    mysql -u root -p
    alter user root@localhost identified by 'xxxxxxxxxxxxx';

    13 开启mysql允许远程访问,连到mysql后执行

    1. mysql> show databases;
    2. +--------------------+
    3. | Database |
    4. +--------------------+
    5. | information_schema |
    6. | mysql |
    7. | performance_schema |
    8. | sys |
    9. +--------------------+
    10. 4 rows in set (0.00 sec)
    11. mysql>
    12. mysql>
    13. mysql> use mysql;
    14. Reading table information for completion of table and column names
    15. You can turn off this feature to get a quicker startup with -A
    16. Database changed
    17. mysql>
    18. mysql>
    19. mysql>
    20. mysql> show tables;
    21. +---------------------------+
    22. | Tables_in_mysql |
    23. +---------------------------+
    24. | columns_priv |
    25. | db |
    26. | engine_cost |
    27. | event |
    28. | func |
    29. | general_log |
    30. | gtid_executed |
    31. | help_category |
    32. | help_keyword |
    33. | help_relation |
    34. | help_topic |
    35. | innodb_index_stats |
    36. | innodb_table_stats |
    37. | ndb_binlog_index |
    38. | plugin |
    39. | proc |
    40. | procs_priv |
    41. | proxies_priv |
    42. | server_cost |
    43. | servers |
    44. | slave_master_info |
    45. | slave_relay_log_info |
    46. | slave_worker_info |
    47. | slow_log |
    48. | tables_priv |
    49. | time_zone |
    50. | time_zone_leap_second |
    51. | time_zone_name |
    52. | time_zone_transition |
    53. | time_zone_transition_type |
    54. | user |
    55. +---------------------------+
    56. 31 rows in set (0.00 sec)
    57. mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
    58. Query OK, 0 rows affected, 1 warning (0.00 sec)

  • 相关阅读:
    Hive 到底有什么用?
    Day714. switch表达式 -Java8后最重要新特性
    7.2 怎样定义函数
    Spring Boot 2.x系列【22】应用监控篇之Health端点
    深入理解JVM虚拟机_1 JVM类加载器设计原理
    vue--vuex 状态管理模式
    大三0基础 java学习求助?
    从API到Agent:万字长文洞悉LangChain工程化设计
    【C++】unordered_set与unordered_map的封装
    OpenMLDB Airflow Connector:让 MLOps 工作流更自由
  • 原文地址:https://blog.csdn.net/m0_37566009/article/details/126967164