linux下安装mysql5.7.11全纪录_记一次linux下安装mysql5.7

一、首先是下载 适应的版本。

地址, https://dev.mysql.com/downloads/mysql/ , 选择版本 mysql-5.7.28-1.el6.x86_64.rpm-bundle.tar 。 我下载的是 bundle ,各个文件全包括在内了。

检查linux是否已经有自带的mysql,如果有,删除掉。

rpm -qa |grep mysql

rpm-qa | grep mysql | xargs rpm -e --nodeps

解压bundle.tar 文件, 执行 rpm -ivh 命令安装 。如果过程中,碰到缺库问题,根据名字手动安装即可。

如果是redhat7/centos7,就用 mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar。在安装过程中,会报出lib冲突。解决办法是,删除mariadb-libs。

[root@master mysql-5.7]# rpm -ivh mysql-community-client-5.7.29-1.el7.x86_64.rpm mysql-community-common-5.7.29-1.el7.x86_64.rpm mysql-community-devel-5.7.29-1.el7.x86_64.rpm mysql-community-libs-5.7.29-1.el7.x86_64.rpm mysql-community-libs-compat-5.7.29-1.el7.x86_64.rpm mysql-community-server-5.7.29-1.el7.x86_64.rpm

warning: mysql-community-client-5.7.29-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

error: Failed dependencies:

mariadb-libs is obsoleted by mysql-community-libs-5.7.29-1.el7.x86_64

mariadb-libs is obsoleted by mysql-community-libs-compat-5.7.29-1.el7.x86_64

[root@master mysql-5.7]# rpm -qa | grep mariadb-libs

mariadb-libs-5.5.64-1.el7.x86_64

[root@master mysql-5.7]# rpm -qa | grep mariadb-libs | xargs rpm -e --nodeps

[root@master mysql-5.7]# rpm -qa | grep mariadb-libs

[root@master mysql-5.7]# rpm -ivh mysql-community-client-5.7.29-1.el7.x86_64.rpm mysql-community-common-5.7.29-1.el7.x86_64.rpm mysql-community-devel-5.7.29-1.el7.x86_64.rpm mysql-community-libs-5.7.29-1.el7.x86_64.rpm mysql-community-libs-compat-5.7.29-1.el7.x86_64.rpm mysql-community-server-5.7.29-1.el7.x86_64.rpm

warning: mysql-community-client-5.7.29-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing... ################################# [100%]

Updating / installing...

1:mysql-community-common-5.7.29-1.e################################# [ 17%]

2:mysql-community-libs-5.7.29-1.el7################################# [ 33%]

3:mysql-community-client-5.7.29-1.e################################# [ 50%]

4:mysql-community-server-5.7.29-1.e################################# [ 67%]

5:mysql-community-devel-5.7.29-1.el################################# [ 83%]

6:mysql-community-libs-compat-5.7.2################################# [100%]

二、启动

service mysqld start

如果是centos7,使用 systemctl 命令。

[root@master mysql-5.7]# systemctl start mysqld

使用 mysql -u root -p 登录,提示要密码。在 /var/log/mysql.log 找到初始的密码。

cat /var/log/mysqld.log | grep password

再次登录即可。

三、首次修改密码

按照提示 必须要用 ALTER USER 的语法。

mysql> ALTER USER USER() IDENTIFIED BY 'Root1234@Root';

Query OK,0 rows affected (0.00 sec)

查看密码的设置要求。

mysql> SHOW VARIABLES LIKE 'vali%';+--------------------------------------+--------+

| Variable_name | Value |

+--------------------------------------+--------+

| validate_password_check_user_name | OFF |

| validate_password_dictionary_file | |

| validate_password_length | 8 |

| validate_password_mixed_case_count | 1 |

| validate_password_number_count | 1 |

| validate_password_policy | MEDIUM |

| validate_password_special_char_count | 1 |

+--------------------------------------+--------+

7 rows in set (0.01 sec)

自定义以上要求,降低密码的复杂度。

mysql> set global validate_password_policy=0;

Query OK,0 rows affected (0.00sec)

mysql> set global validate_password_special_char_count = 0

->;

Query OK,0 rows affected (0.00sec)

mysql> set global validate_password_length=4

->;

Query OK,0 rows affected (0.01 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.01 sec)

mysql> usemysql;

Readingtable information for completion of table and columnnames

You can turnoff this feature to get a quicker startup with -ADatabasechanged

mysql>mysql>mysql>show tables;+---------------------------+

| Tables_in_mysql |

+---------------------------+

| 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 |

+---------------------------+

31 rows in set (0.00sec)

mysql> desc user;+------------------------+-----------------------------------+------+-----+-----------------------+-------+

| Field | Type | Null | Key | Default | Extra |

+------------------------+-----------------------------------+------+-----+-----------------------+-------+

| Host | char(60) | NO | PRI | | |

| User | char(32) | NO | PRI | | |

| Select_priv | enum('N','Y') | NO | | N | |

| Insert_priv | enum('N','Y') | NO | | N | |

| Update_priv | enum('N','Y') | NO | | N | |

| Delete_priv | enum('N','Y') | NO | | N | |

| Create_priv | enum('N','Y') | NO | | N | |

| Drop_priv | enum('N','Y') | NO | | N | |

| Reload_priv | enum('N','Y') | NO | | N | |

| Shutdown_priv | enum('N','Y') | NO | | N | |

| Process_priv | enum('N','Y') | NO | | N | |

| File_priv | enum('N','Y') | NO | | N | |

| Grant_priv | enum('N','Y') | NO | | N | |

| References_priv | enum('N','Y') | NO | | N | |

| Index_priv | enum('N','Y') | NO | | N | |

| Alter_priv | enum('N','Y') | NO | | N | |

| Show_db_priv | enum('N','Y') | NO | | N | |

| Super_priv | enum('N','Y') | NO | | N | |

| Create_tmp_table_priv | enum('N','Y') | NO | | N | |

| Lock_tables_priv | enum('N','Y') | NO | | N | |

| Execute_priv | enum('N','Y') | NO | | N | |

| Repl_slave_priv | enum('N','Y') | NO | | N | |

| Repl_client_priv | enum('N','Y') | NO | | N | |

| Create_view_priv | enum('N','Y') | NO | | N | |

| Show_view_priv | enum('N','Y') | NO | | N | |

| Create_routine_priv | enum('N','Y') | NO | | N | |

| Alter_routine_priv | enum('N','Y') | NO | | N | |

| Create_user_priv | enum('N','Y') | NO | | N | |

| Event_priv | enum('N','Y') | NO | | N | |

| Trigger_priv | enum('N','Y') | NO | | N | |

| Create_tablespace_priv | enum('N','Y') | NO | | N | |

| ssl_type | enum('','ANY','X509','SPECIFIED') | NO | | | |

| ssl_cipher | blob | NO | | NULL | |

| x509_issuer | blob | NO | | NULL | |

| x509_subject | blob | NO | | NULL | |

| max_questions | int(11) unsigned | NO | | 0 | |

| max_updates | int(11) unsigned | NO | | 0 | |

| max_connections | int(11) unsigned | NO | | 0 | |

| max_user_connections | int(11) unsigned | NO | | 0 | |

| plugin | char(64) | NO | | mysql_native_password | |

| authentication_string | text | YES | | NULL | |

| password_expired | enum('N','Y') | NO | | N | |

| password_last_changed | timestamp | YES | | NULL | |

| password_lifetime | smallint(5) unsigned | YES | | NULL | |

| account_locked | enum('N','Y') | NO | | N | |

+------------------------+-----------------------------------+------+-----+-----------------------+-------+

45 rows in set (0.00sec)

mysql> select Host,User,authentication_string from user;+-----------+---------------+-------------------------------------------+

| Host | User | authentication_string |

+-----------+---------------+-------------------------------------------+

| localhost | root | *1E0532C5DAF747138FB6C69FE370B6213B6EE5E4 |

| localhost | mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |

| localhost | mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |

+-----------+---------------+-------------------------------------------+

3 rows in set (0.00 sec)

mysql> update user set host='%' where User='root';

Query OK,1 row affected (0.00sec)

Rows matched:1 Changed: 1 Warnings: 0

mysql> update user set authentication_string=PASSWORD('root123') where User='root';

Query OK,1 row affected, 1 warning (0.00sec)

Rows matched:1 Changed: 1 Warnings: 1mysql> select Host,User,authentication_string from user;+-----------+---------------+-------------------------------------------+

| Host | User | authentication_string |

+-----------+---------------+-------------------------------------------+

| % | root | *FAAFFE644E901CFAFAEC7562415E5FAEC243B8B2 |

| localhost | mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |

| localhost | mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |

+-----------+---------------+-------------------------------------------+

3 rows in set (0.00 sec)

到这里, 修改密码完成。最后要重启mysql服务,才生效。

[root@master mysql-5.7]# systemctl status mysqld

你可能感兴趣的:(linux下安装mysql5.7.11全纪录_记一次linux下安装mysql5.7)