您的位置:首页 > 运维架构 > Linux

每日MySQL之001:MySQL在SUSE Linux下的安装

2017-08-01 00:21 169 查看
SUSE版本为11.4

1. 下载与安装

1.1 download
https://dev.mysql.com/downloads/mysql/

下载文件如下,这里下载的是社区版本,以下命令,如无特别说明,均为root用户在家目录下操作的:

db2a:~ # ls mysql*

mysql-5.7.19-1.sles11.x86_64.rpm-bundle.tar

1.2 Linux安装指引
https://dev.mysql.com/doc/refman/5.7/en/linux-installation-rpm.html

db2a:~ # tar -xvf mysql-5.7.19-1.sles11.x86_64.rpm-bundle.tar

mysql-community-test-5.7.19-1.sles11.x86_64.rpm

mysql-community-server-5.7.19-1.sles11.x86_64.rpm

mysql-community-libs-5.7.19-1.sles11.x86_64.rpm

mysql-community-embedded-5.7.19-1.sles11.x86_64.rpm

mysql-community-devel-5.7.19-1.sles11.x86_64.rpm

mysql-community-embedded-devel-5.7.19-1.sles11.x86_64.rpm

mysql-community-client-5.7.19-1.sles11.x86_64.rpm

mysql-community-common-5.7.19-1.sles11.x86_64.rpm

db2a:~ # zypper install mysql-community-{server,client,common,libs}-*

对于Red Hat Enterprise Linux, Oracle Linux, CentOS, 和 Fedora,需要把zypper换成yum

2. 启动与停止mysql服务

安装完成之后,不会自动启动mysql服务,对于Red Hat Enterprise Linux, Oracle Linux, CentOS, 和 Fedora,服务名为mysqld:

service mysqld start

对于SLES命令如下:

db2a:~ # service mysql start

Starting service MySQL:            done

db2a:~ # service mysql status

Checking for service MySQL:        running

db2a:~ # netstat -an | grep -i 3306

tcp        0      0 :::3306                 :::*                    LISTEN 

第一次启动时,MySQL会生成一个超级账户'root'@'localhost',它的临时密码放到mysql错误日志里,对于Red Hat Enterprise Linux, Oracle Linux, CentOS, 和 Fedora,查询方式如下

grep 'temporary password' /var/log/mysqld.log

对于SLES,查询命令如下,注意,最后的逗号也是密码的一部分:

db2a:~ # grep 'temporary password' /var/log/mysql/mysqld.log

2017-07-23T15:22:23.397239Z 1 [Note] A temporary password is generated for root@localhost:thu1w+/XKf.,

使用刚刚得到的临时密码登录并修改密码为qingsong

db2a:~ # mysql -u root -p

Enter password:  <--这里输入thu1w+/XKf.,

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 8

Server version: 5.7.19

Copyright (c) 2000, 2017, 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> ALTER USER 'root'@'localhost' IDENTIFIED BY 'qingsong';

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

mysql> set global validate_password_policy=0;

Query OK, 0 rows affected (0.01 sec)

mysql> set global validate_password_length=1;

Query OK, 0 rows affected (0.00 sec)

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'qingsong';

Query OK, 0 rows affected (0.00 sec)

mysql>  SHOW VARIABLES LIKE 'validate_password%';

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

| Variable_name                        | Value |

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

| validate_password_check_user_name    | OFF   |

| validate_password_dictionary_file    |       |

| validate_password_length             | 4     |

| validate_password_mixed_case_count   | 1     |

| validate_password_number_count       | 1     |

| validate_password_policy             | LOW   |

| validate_password_special_char_count | 1     |

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

7 rows in set (0.02 sec)

mysql> exit

Bye

停止MySQL服务:

db2a:~ # service mysql stop

Shutting down service MySQL:             done

db2a:~ # service mysql status

Checking for service MySQL:              unused

https://dev.mysql.com/doc/refman/5.7/en/validate-password-options-variables.html

http://www.2cto.com/database/201310/250287.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  MySQL 安装 启动 SUSE