centos 7.3 mysql5.7 安裝
阿新 • • 發佈:2019-02-19
[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