SLE12 Server 在线安装MySQL Server
博客专区 > muman 的博客 > 博客详情
SLE12 Server 在线安装MySQL Server
muman 发表于2年前
SLE12 Server 在线安装MySQL Server
  • 发表于 2年前
  • 阅读 19
  • 收藏 0
  • 点赞 0
  • 评论 0

【腾讯云】买域名送云解析+SSL证书+建站!>>>   

摘要: 使用Zypper在线安装MySQL Server

1、确认是否安装了MYSQL 旧版本或应用

# rpm -qa|grep mysql

>libmysqlclient18-10.0.11-6.4.x86_64

>libqt4-sql-mysql-4.8.6-2.6.x86_64

 

2、卸载旧版本或应用

#rpm -ev libqt4-sql-mysql-4.8.6-2.6.x86_64

>Preparing packages...

>libqt4-sql-mysql-4.8.6-2.6.x86_64

 

# rpm -ev libmysqlclient18-10.0.11-6.4.x86_64

>Preparing packages...

>libmysqlclient18-10.0.11-6.4.x86_64

 

3、更新Zypper 库(Adding the MySQL SLES Repository)

# wget http://repo.mysql.com//mysql57-community-release-sles12-7.noarch.rpm

>--2016-05-12 22:06:11--  http://repo.mysql.com//mysql57-community-release-sles12-7.noarch.rpm

>Resolving repo.mysql.com (repo.mysql.com)... 23.13.185.161

>Connecting to repo.mysql.com (repo.mysql.com)|23.13.185.161|:80... connected.

>HTTP request sent, awaiting response... 200 OK

>Length: 8593 (8.4K) [application/x-redhat-package-manager]

>Saving to: mysql57-community-release-sles12-7.noarch.rpm?

>

>100%[======================================>] 8,593       --.-K/s   in 0s     

>

>2016-05-12 22:06:11 (97.5 MB/s) - 鈓ysql57-community-release-sles12-7.noarch.rpm?saved [8593/8593]

 

# rpm -Uvh mysql57-community-release-sles12-7.noarch.rpm

>warning: mysql57-community-release-sles12-7.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

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

>Updating / installing...

>  1:mysql57-community-release-sles12-################################# [100%]

 

# zypper repos|grep mysql.*community

>2 | mysql-connectors-community              | MySQL Connectors Community                  | Yes     | No    

>3 | mysql-connectors-community-source | MySQL Connectors Community - Source   | No      | No    

>4 | mysql-tools-community                         | MySQL Tools Community                             | Yes     | No    

>5 | mysql-tools-community-source            | MySQL Tools Community - Source              | No      | No    

>6 | mysql56-community                               | MySQL 5.6 Community Server                     | No      | No    

>7 | mysql56-community-source                  | MySQL 5.6 Community Server - Source      | No      | No    

>8 | mysql57-community                               | MySQL 5.7 Community Server                      | Yes     | No    

>9 | mysql57-community-source                  | MySQL 5.7 Community Server - Source       | No      | No    

 

*本次安装mysql57-community  如果为非Yes 则需要使用以下命令

# zypper repos -E |grep mysql57-community

>8 | mysql57-community                               | MySQL 5.7 Community Server                      | Yes     | No    

*使用以下命令是禁止

>mysqlrouter01:~ # sudo zypper modifyrepo -d mysql57-community

>Repository 'mysql57-community' has been successfully disabled.

*使用以下命令是允许

# sudo zypper modifyrepo -e mysql57-community

>Repository 'mysql57-community' has been successfully enabled.

 

# sudo zypper refresh

>Repository 'SLES12-12-0' is up to date.

>Retrieving repository 'MySQL Connectors Community' metadata ----------------------------------------------------[\]

>File 'repomd.xml' from repository 'MySQL Connectors Community' is signed with an unknown key '8C718D3B5072E1F5'. >>Continue? [yes/no] (no): yes

>Retrieving repository 'MySQL Connectors Community' metadata .................................................[done]

>Building repository 'MySQL Connectors Community' cache ......................................................[done]

>Retrieving repository 'MySQL Tools Community' metadata ---------------------------------------------------------[/]

>File 'repomd.xml' from repository 'MySQL Tools Community' is signed with an unknown key '8C718D3B5072E1F5'. Continue? [yes/no] (no): yes

>Retrieving repository 'MySQL Tools Community' metadata ......................................................[done]

>Building repository 'MySQL Tools Community' cache ...........................................................[done]

>Retrieving repository 'MySQL 5.7 Community Server' metadata ----------------------------------------------------[/]

>File 'repomd.xml' from repository 'MySQL 5.7 Community Server' is signed with an unknown key '8C718D3B5072E1F5'. Continue? [yes/no] (no): yes

>Retrieving repository 'MySQL 5.7 Community Server' metadata .................................................[done]

>Building repository 'MySQL 5.7 Community Server' cache ......................................................[done]

>All repositories have been refreshed.

 

4、安装MySQL 5.7 Server (Installing MySQL with Zypper)

# sudo zypper install mysql-community-server

>Loading repository data...

>Reading installed packages...

>Resolving package dependencies...

>

>The following 4 NEW packages are going to be installed:

>  mysql-community-client mysql-community-common mysql-community-libs mysql-community-server

>

>4 new packages to install.

>Overall download size: 148.6 MiB. Already cached: 227.1 KiB  After the operation, additional 801.7 MiB will be

used.

>Continue? [y/n/? shows all options] (y): y

>In cache mysql-community-common-5.7.12-1.sles12.x86_64.rpm                    (1/4), 227.1 KiB (  2.5 MiB unpacked)

>Retrieving package mysql-community-libs-5.7.12-1.sles12.x86_64                     (2/4),   1.9 MiB (  9.4 MiB unpacked)

>Retrieving: mysql-community-libs-5.7.12-1.sles12.x86_64.rpm .....................................[done (9.0 KiB/s)]

>Retrieving package mysql-community-client-5.7.12-1.sles12.x86_64                  (3/4),  21.3 MiB (105.3 MiB unpacked)

>Retrieving: mysql-community-client-5.7.12-1.sles12.x86_64.rpm ..................................[done (45.8 KiB/s)]

>Retrieving package mysql-community-server-5.7.12-1.sles12.x86_64                (4/4), 125.4 MiB (684.5 MiB unpacked)

>Retrieving: mysql-community-server-5.7.12-1.sles12.x86_64.rpm ..................................[done (23.9 KiB/s)]

>Checking for file conflicts: ................................................................................[done]

>(1/4) Installing: mysql-community-common-5.7.12-1.sles12 ....................................................[done]

>Additional rpm output:

>warning: /var/cache/zypp/packages/mysql57-community/mysql-community-common-5.7.12-1.sles12.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

>

>

>(2/4) Installing: mysql-community-libs-5.7.12-1.sles12 ......................................................[done]

>Additional rpm output:

>warning: /var/cache/zypp/packages/mysql57-community/mysql-community-libs-5.7.12-1.sles12.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

>

>

>(3/4) Installing: mysql-community-client-5.7.12-1.sles12 ....................................................[done]

>Additional rpm output:

>warning: /var/cache/zypp/packages/mysql57-community/mysql-community-client-5.7.12-1.sles12.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

>

>

>(4/4) Installing: mysql-community-server-5.7.12-1.sles12 ....................................................[done]

>Additional rpm output:

>warning: /var/cache/zypp/packages/mysql57-community/mysql-community-server-5.7.12-1.sles12.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

 

5、初始化配置MySQL 5.7 (Starting the MySQL Server)

# sudo service mysql stop

# sudo service mysql start

 

*查询安装系统时所生成的随机密码

# grep "password" /var/log/mysql/mysqld.log

2016-05-12T15:35:31.600553Z 1 [Note] A temporary password is generated for root@localhost : tcODfg>mw2qm

 

# mysql -uroot -p                             --密码为所查询到的随机密码

>Enter password:

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

>Your MySQL connection id is 7

>Server version: 5.7.12

>

>Copyright (c) 2000, 2016, 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.

 

 *测试一下,报错ERROR 1820 (HY000)

mysql> select 1;                                                                                                                         

>ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

 

*初始化密码,密码复杂性报错

mysql> set password=PASSWORD('root123');                                                             

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

 

这个其实与validate_password_policy的值有关。

validate_password_policy有以下取值:

Policy

Tests Performed

0 or LOW

Length

1 or MEDIUM

Length; numeric, lowercase/uppercase, and special characters

2 or STRONG

Length; numeric, lowercase/uppercase, and special characters; dictionary file

默认为:1 or MEDIUM

 

*修改密码复杂性值:0 or LOW

mysql> set global validate_password_policy=0;

> Query OK, 0 rows affected (0.00 sec)

*以下命令在未进行root密码初始化的情况下,未必会执行成功,只需明白已将密码复杂性改为必须为8位以上的密码

mysql> select @@validate_password_length;

>+----------------------------+

>| @@validate_password_length |

>+----------------------------+

>|                          8 |

>+----------------------------+

>1 row in set (0.00 sec)

 

*修改初始密码;

mysql> SET PASSWORD = PASSWORD('root123456');

>Query OK, 0 rows affected, 1 warning (0.01 sec)

 

 *再次测试,结果如下

mysql> select 1;

> +---+

>| 1 |

>+---+

>| 1 |

>+---+

>1 row in set (0.00 sec)

 

mysql> show databases;

>+--------------------+

>| Database           |

>+--------------------+

>| information_schema |

>| mysql              |

>| performance_schema |

>| sys                |

>+--------------------+

>4 rows in set (0.00 sec)

 

mysql> use mysql;

>Reading table information for completion of table and column names

>You can turn off this feature to get a quicker startup with -A

>

>Database changed

 

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.00 sec)

 

mysql> quit

>Bye

  • 打赏
  • 点赞
  • 收藏
  • 分享
共有 人打赏支持
粉丝 0
博文 1
码字总数 1247
×
muman
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: