[root@localhost ~]# systemctl start mysqld#启动报错:Job for mysqld.service failed because the control process exited with error code.#日志报错:[ERROR] [MY-012271] [InnoDB] The innodb_system data file 'ibdata1' must be writable#解决方案:[root@localhost ~]# chmod -R 777 /usr/local/mysql/data/ #mysql5.7以前版本[root@localhost ~]# chmod -R 777 /var/lib/mysql #mysql5.7之后版本
查看MySQL运行状态
[root@localhost ~]# systemctl status mysqld
关闭MySQL
[root@localhost ~]# systemctl stop mysqld
重启MySQL
[root@localhost ~]# systemctl restart mysqld
修改密码
[root@localhost ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 5.6.46 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, 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('123456');
设置开机自启动
[root@localhost ~]# vi /etc/rc.local#!/bin/bash# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES## It is highly advisable to create own systemd services or udev rules# to run scripts during boot instead of using this file.## In contrast to previous versions due to parallel execution during boot# this script will NOT be run after all other services.## Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure# that this script will be executed during boot.touch /var/lock/subsys/local
service mysqld start #设置MySQL开机自启动
[root@localhost ~]# mysql -u root -p
Enter password: #默认无密码,回车直接进入mysql界面
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.17 Source distribution
Copyright (c) 2000, 2019, 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 WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.01 sec)
mysql>quit
修改权限
[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 8.0.17 Source distribution
Copyright (c) 2000, 2019, 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> use mysql;#选择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>select'host' from user where user='root';#查看mysql库中的user表的host值(即可进行连接访问的主机/IP名称)
+------+
| host |
+------+
| host |
+------+
1 row inset(0.00 sec)
mysql> update user set host ='%' where user ='root';#修改host值(以通配符%的内容增加主机/IP地址),当然也可以直接增加IP地址
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;#刷新MySQL的系统权限相关表
Query OK, 0 rows affected (0.01 sec)
mysql>select'host' from user where user='root';
+------+
| host |
+------+
| host |
+------+
1 row inset(0.00 sec)
mysql> quit
Bye
[root@localhost ~]# systemctl restart mysqld #重启mysql服务
安装zookeeper
tar包离线安装
#安装[root@localhost ~]# tar zxvf zookeeper-3.4.14.tar.gz -C /usr[root@localhost ~]# cp /usr/zookeeper-3.4.14/conf/zoo_sample.cfg /usr/zookeeper-3.4.14/conf/zoo.cfg#启动[root@localhost ~]# cd /usr/zookeeper-3.4.14/bin/[root@localhost bin]# ./zkServer.sh start ../conf/zoo.cfg
ZooKeeper JMX enabled by default
Using config: ../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@localhost bin]# jps
2024 QuorumPeerMain
2041 Jps
#停止[root@localhost bin]# ./zkServer.sh stop ../conf/zoo.cfg
ZooKeeper JMX enabled by default
Using config: ../conf/zoo.cfg
Stopping zookeeper ... STOPPED