1,到官网下载安装包:
https://www.mysql.com/
2, 安装:
[root@master /opt/bigdata/service]# rpm -ivh mysql-community-common-5.7.22-1.el7.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:mysql-community-common-5.7.22-1.e################################# [100%] [root@master /opt/bigdata/service]# rpm -ivh mysql-community-libs-5.7.22-1.el7.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:mysql-community-libs-5.7.22-1.el7################################# [100%] [root@master /opt/bigdata/service]# rpm -ivh mysql-community-client-5.7.22-1.el7.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:mysql-community-client-5.7.22-1.e################################# [100%] [root@master /opt/bigdata/service]# rpm -ivh mysql-community-server- mysql-community-server-5.7.22-1.el7.x86_64.rpm mysql-community-server-minimal-5.7.22-1.el7.x86_64.rpm [root@master /opt/bigdata/service]# rpm -ivh mysql-community-server-5.7.22-1.el7.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:mysql-community-server-5.7.22-1.e################################# [100%]
3, 初始化密码:
[root@master /opt/bigdata/service]# mysqld --initialize --user=mysql [root@master /opt/bigdata/service]# cat cat /var/log/mysqld.log | grep password cat: cat: No such file or directory 2018-05-28T13:03:28.527740Z 1 [Note] A temporary password is generated for root@localhost: 0wEeI2ylfm?.
4, 启动mysql修改密码:
systemctl start mysqld.service [root@master /opt/ClusterBuildScripts]# mysql -u root -p Enter password: (输入3中得到的初始化密码:) Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.22 Copyright (c) 2000, 2018, 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> set password = password('12345678'); Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> grant all privileges on *.* to 'root' @'%' identified by 'yourpassword'; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> exit Bye
5, mysql 启动和停止相关命令
centos 默认启动方式: systemctl start mysqld.service 启动: 使用 service 启动:service mysqld start 使用 mysqld 脚本启动:/etc/inint.d/mysqld start 使用 safe_mysqld 启动:safe_mysqld& 停止: 使用 service 启动:service mysqld stop 使用 mysqld 脚本启动:/etc/inint.d/mysqld stop mysqladmin shutdown 重启: 使用 service 启动:service mysqld restart 使用 mysqld 脚本启动:/etc/inint.d/mysqld restart
6, mysql 自启动:
[root@master /]# systemctl list-unit-files | grep mysql mysqld.service enabled mysqld@.service disabled [root@master /]# centos 默认自启动 可以进行取消: systemctl disable mysqld 然后在/etc/rc.local 先执行systemctl start mysqld
评论专区