码迷,mamicode.com
首页 > 数据库 > 详细

Centos7下MySql5.7安装及配置

时间:2018-07-10 23:31:39      阅读:287      评论:0      收藏:0      [点我收藏+]

标签:generate   public   火墙   gtid   master   format   inf   not   client   

安装MySql

  1. 软件包:

    • mysql-community-libs-5.7.22-1.el7.x86_64.rpm
    • mysql-community-common-5.7.22-1.el7.x86_64.rpm
    • mysql-community-client-5.7.22-1.el7.x86_64.rpm
    • mysql-community-server-5.7.22-1.el7.x86_64.rpm
  2. 安装流程(有依赖关系)

         rpm -ivh mysql-community-libs-5.7.22-1.el7.x86_64.rpm
         rpm -ivh mysql-community-common-5.7.22-1.el7.x86_64.rpm
         rpm -ivh mysql-community-client-5.7.22-1.el7.x86_64.rpm
         rpm -ivh mysql-community-server-5.7.22-1.el7.x86_64.rpm

配置MySql

  1. 启动MySql服务
    systemctl start mysqld.service
  1. 查看MySql服务状态
    systemctl status mysqld.service
  1. 使用RPM软件包进行安装会生成一个初始随机密码,该密码被写入服务器错误日志(/var/log/mysqld.log)。
    [server@bogon ~]$ grep ‘temporary password‘ /var/log/mysqld.log 
    2018-07-10T12:35:03.497044Z 1 [Note] A temporary password is generated for root@localhost: (hfu*hjnt3W;
  1. 使用mysql命令, 用户名root及得到的随机密码登入MySql服务器进行密码修改
    [server@bogon ~]$ mysql -u root -p
    Enter password: (hfu*hjnt3W;

    mysql> ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘new_password‘;

注意: new_password长度必须大于8个字符,且有大小写、数字、特殊字符。

  1. 在防火墙中开启3306端口(MySql服务器莫扔过高端口)并查看端口状态
    shell> firewall-cmd --zone=public --add-port=3306/tcp --permanent
    shell> firewall-cmd --reload
    shell> firewall-cmd --zone=public --list-ports

小技巧

  1. 使用mysqlshow查看存在那些数据库或数据库中存在的表列表
shell> mysqlshow -u root -p
+--------------------+
|     Databases      |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+

shell> mysqlshow -u root -p mysql
Database: mysql
+---------------------------+
|          Tables           |
+---------------------------+
| columns_priv              |
| db                        |
| engine_cost               |
| event                     |
| func                      |
| general_log               |
| gtid_executed             |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| innodb_index_stats        |
| innodb_table_stats        |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| server_cost               |
| servers                   |
| slave_master_info         |
| slave_relay_log_info      |
| slave_worker_info         |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+

Centos7下MySql5.7安装及配置

标签:generate   public   火墙   gtid   master   format   inf   not   client   

原文地址:https://www.cnblogs.com/Focus-Flying/p/9291917.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!