MySql ocp认证之MySql安装(一)
一、mysql安装:
[root@VM-24-5-centos mysql]# tar -xvf mysql-5.7.38-linux-glibc2.12-x86_64.tar
[root@VM-24-5-centos mysql]# mv mysql-5.7.38-linux-glibc2.12-x86_64 /usr/local/mysql
[root@VM-24-5-centos mysql]# cd /usr/local/mysql/
[root@VM-24-5-centos mysql]# ls
bin docs include lib LICENSE man README share support-files
# 运行时会创建一个socket,存放在/var/lib/mysql下,存放ip地址、端口号
[root@VM-24-5-centos mysql]# mkdir -p /var/lib/mysql
[root@VM-24-5-centos mysql]# mkdir -p /usr/local/mysql/log
[root@VM-24-5-centos mysql]# mkdir -p /usr/local/mysql/log/error.err
[root@VM-24-5-centos mysql]# mkdir -p /usr/local/mysql/log/query.err
[root@VM-24-5-centos mysql]# mkdir -p /usr/local/mysql/data[root@VM-24-5-centos ~]# groupadd mysql
[root@VM-24-5-centos ~]# useradd -r -g mysql -s /bin/false mysql
[root@VM-24-5-centos local]# chown -R mysql:mysql /usr/local/mysql
二、配置文件
查看mysql配置文件路径:
/usr/local/mysql/bin/mysqld --verbose --help |grep -A 1 ‘Default options’
具体内容:
[mysql]
default-character-set=utf8mb4
socket=/var/lib/mysql/mysql.sock[mysqld]
port=3306
basedir=/usr/local/mysql
datadir=/usr/local/mysql/datacharacter-set-server=utf8mb4
default-storage-engine=INNODBmax_allowed_packet = 16M
innodb_buffer_pool_size=200M
explicit_defaults_for_timestamp=1log-output=FILE
general_log=0
general_log_file=/usr/local/mysql/log/general.err
slow_query_log=ON
slow_query_log_file=/usr/local/mysql/log/query.err
long_query_time=10
log-error=/usr/local/mysql/log/error.err
default-authentication-plugin=mysql_native_password
三、数据库初始化:
[root@VM-24-5-centos ~]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
注意:–user参数指定初始化的用户,如果不指定则按照当前执行命令的用户进行初始化,如果是root用户,则使用root用户进行初始化各种文件夹。
初始化完毕后可以在data目录下看到有很多数据库实例:
[root@VM-24-5-centos mysql]# cd data/
[root@VM-24-5-centos data]# ls
auto.cnf ca.pem client-key.pem ibdata1 ib_logfile1 performance_schema public_key.pem server-key.pem
ca-key.pem client-cert.pem ib_buffer_pool ib_logfile0 mysql private_key.pem server-cert.pem sys
有问题可以查看log/error.err文件查看
2022-08-25T07:15:02.171562Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-08-25T07:15:02.244319Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-08-25T07:15:02.313131Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: a2ece67d-2445-11ed-a8dd-5254009245d5.
2022-08-25T07:15:02.324209Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-08-25T07:15:02.613856Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-08-25T07:15:02.613865Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-08-25T07:15:02.614325Z 0 [Warning] CA certificate ca.pem is self signed.
2022-08-25T07:15:02.687151Z 1 [Note] A temporary password is generated for root@localhost: ypjx/B+-X5xk
最后一行显示产生了一个临时密码:ypjx/B±X5xk
四、mysql的启动和停止
启动mysql,要指定.cnf文件启动
/usr/local/mysql-slave/bin/mysqld --defaults-file=/usr/local/mysql-slave/conf/my.cnf &
也可以通过mysqld_safe启动,当用mysqld_safe启动时,mysqld进程如果挂了,mysqld_safe会自动重启msqld进程。
/usr/local/mysql-slave/bin/mysqld_safe --defaults-file=/usr/local/mysql-slave/conf/my.cnf --user=mysql &
停止MYSQL,需要指定对应的sock文件。
/usr/local/mysql-slave/bin/mysqladmin -uroot -p shutdowm -S /var/lib/mysql-slave/mysql.sock
登陆3307端口的mysql
/usr/local/mysql-slave/bin/mysql -S /var/lib/mysql-slave/mysql.sock -P 3307
下一步:配置Linux启动和停止脚本
[root@VM-24-5-centos log]# vim /usr/lib/systemd/system/mysqld.service
[Unit]
Description=Mysql Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE=65536
LimitNPROC=65536
重新加载systemctl配置文件:
[root@VM-24-5-centos log]# systemctl daemon-reload
启动mysql服务
[root@VM-24-5-centos mysql]# systemctl start mysqld
查看mysql进程:
[root@VM-24-5-centos mysql]# ps -ef|grep mysql
mysql 265975 1 0 12:22 ? 00:00:00 /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
root 267275 262410 0 12:28 pts/0 00:00:00 grep --color=auto mysql
查看mysql进程状态:
[root@VM-24-5-centos mysql]# systemctl status mysqld
随机启动:
[root@VM-24-5-centos mysql]# systemctl enable mysqld
五、mysql登录
执行mysql命令,报下面的错:
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
需要安装下面的包:
yum install -y ncurses-compat-libs
执行mysql命令,报下面的错:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
创建的mysql.sock在/tmp/目录下,需要创建个软连接指向/var/lib/mysql/mysql.sock
ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
使用临时密码登录mysql:
[root@VM-24-5-centos log]# mysql -uroot -pypjx/B±X5xk
修改root密码:
mysql> alter user root@‘localhost’ identified with mysql_native_password by ‘123456’;
mysql> flush privileges;
允许root远程登录:
mysql的登录名实际由两部分组成,一个是用户名,一个是登录的地址。可以看一下mysql库中的user表,主键是host和user:
mysql> desc user;
+------------------------+-----------------------------------+------+-----+-----------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+-----------------------------------+------+-----+-----------------------+-------+
| Host | char(60) | NO | PRI | | |
| User | char(32) | NO | PRI | | |
此时,用外网的root用户登录不了mysql,需要手动创建个host为%的root用户
mysql> create user root@‘%’ identified by ‘123456’;
mysql> flush privileges;
外网登录后无法创建数据库,提示没有权限。需要使用mysql进行授权:
mysql> grant all on *.* to root@'%';
mysql> flush privileges;
all表示所有权限。
MySql ocp认证之MySql安装(一)相关推荐
- mysql 5.6ocp认证_花5百购买的mysql ocp认证IZO-883 考试题库 准确率达到百分之八九十...
[实例简介] 题库真实有效,花5百购买的mysql ocp认证IZO-883 考试题库 准确率达到百分之八九十 [实例截图] [核心代码] 21616308mysqlocp认证IZO-883 └── ...
- mysql ocp 认证 题库_MySQL 8 OCP(1Z0-908)认证考试题库原题(第10题)
Mysql 8.0 OCP认证考试原题题库整理(CUUG内部资料)-第10题 Choose the best answer. Examine these commands, which execute ...
- 【MySQL附录】A6:MySQL OCP 认证考试最详细最准确报考流程(2020年)
Oracle将MySQL纳入旗下后,也参照Oracle数据库,推出针对MySQL的OCP认证(目前MySQL没有OCM级别). MySQL8.0软件在2018年4正式发布后,终于在2020年1月底,O ...
- mysql ocp 认证 题库_MySQL 8 OCP(1Z0-908)认证考试题库原题(第12题)
Mysql 8.0 OCP认证考试原题题库整理(CUUG内部资料)-第12题 Choose the best answer. You plan to upgrade your MySQL 5.7 in ...
- 51cto MySQL OCP认证精品班5期视频
个人考试经验 已报名51mysql ocp 认证课,需要评论.为了简单解释一下测试问题,MySQL OCP现在有5.7和8.0版本.由于8.0版本刚刚发布,题库相对较少(以前在网络上参加过考试的人会根 ...
- mysql ocp 认证 题库_Mysql 8.0 OCP认证考试原题题库整理(CUUG内部资料)-第1题
Mysql 8.0 OCP认证考试原题题库整理(CUUG内部资料)-第1题 1.Choose the best answer. Examine these statements and output: ...
- mysql ocp 认证 题库_Mysql 8.0 OCP认证考试原题整理(CUUG内部题库)-第4题
Mysql 8.0 OCP认证考试原题整理(CUUG内部题库)-第4题 时间:2020-12-01 来源: Mysql 8.0 OCP认证考试原题整理(CUUG内部题库)-第4题 4.Choose t ...
- MySql ocp认证之备份与恢复(四)
一.使用二进制文件进行数据恢复 常用的方式有两种: 1.使用时间点恢复:通常在换会员物理备份或mysqldump备份之后,再用此方法还原完整备份至当前时间以来的数据更改,以确保数据完整性. 2.使用时 ...
- 51cto MySQL OCP认证精品班5期
Oracle的SQL调优是一个复杂的主题,甚至是需要整本书来介绍Oracle SQL调优的细微差别.不过有一些基本的规则是每个Oracle DBA都需要跟从的,这些规则可以改善他们系统的性能.SQL调 ...
最新文章
- Redis源码解析——字典遍历
- js计算前三个月的时间精确到时分秒
- 比较MongoDB在公有云上的性能:AWS、Azure和Digital Ocean
- 使用基本的socket函数
- java经典50题_JAVA经典算法50题(3)【面试+工作】
- 用户请求队列化_爬虫架构消息队列应用场景及ActiveMQ、RabbitMQ、RocketMQKafka
- Mysql的锁机制之表锁
- 难道我的事,又要落空么。。。
- Python的列表推倒式、生成器及迭代器
- mysql结果以字符串显示不出来,mysql – 为什么SQl MATCH AGAINST找不到结果中只有3个字符的结果?...
- 洛谷P3392 涂国旗
- 苹果前CEO斯卡利变身创业导师:欲寻下个乔布斯
- 易商云页面认证失败是什么情况_Serverless 云原生框架 Malagu:认证与授权
- 关于年会抢红包游戏的一个思考
- Layui 中 formSelects 的使用
- Linux cut 实例
- Docker镜像重命名
- 蚁群算法原理及Matlab实现
- cad 切图_CAD怎么切图?
- sweetalert加载弹窗定时自动关闭