CentOS7安装MySQL5.7
环境:
操作系统: CentOS7.0
MySQL版本:mysql-5.7.23-1.el7.x86_64
准备:
安装步骤
<1>检查卸载mariadb-lib
#检查
root的初始密码[root@imok ~]# rpm -qa|grep mariadb
mariadb-libs-5.5.35-3.el7.x86_64
#卸载
[root@imok ~]# rpm -e mariadb-libs-5.5.35-3.el7.x86_64 --nodeps
<2>上传mysql安装包并解压
[root@]# tar -xvf mysql-5.7.23-1.el7.x86_64.rpm-bundle.tar -C /opt/mysql/
<3>安装相关依赖
安装mysql-server需要以下安装包
mysql-community-common-5.7.23-1.el7.x86_64.rpm
mysql-community-libs-5.7.23-1.el7.x86_64.rpm
mysql-community-client-5.7.23-1.el7.x86_64.rpm
mysql-community-server-5.7.23-1.el7.x86_64.rpm
安装以上四个需要安装 libaio依赖和 net-tools
安装libbaio
[root@imok mysql]# yum -y install libaio
安装net-tools
[root@imok mysql]# yum install net-tools
未安装net-tools报错提⽰:
warning: mysql-community-common-5.7.23-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
net-tools is needed by mysql-community-server-5.7.23-1.el7.x86_64
<4>安装mysql-server
[root@imok mysql]# rpm -ivh mysql-community-common-5.7.23-1.el7.x86_64.rpm mysql-community-libs-5.7.23-1.el7.x86_64.rpm mysql-community-client-5.7.23-
1.el7.x86_64.rpm mysql-community-server-5.7.23-1.el7.x86_64.rpm
warning: mysql-community-common-5.7.23-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
< >>>>>>### [100%]
Updating /
1:mysql-community-common-5.7.23-1.e>>>>>>### [ 25%]
2:mysql-community-libs-5.7.23-1.el7>>>>>>### [ 50%]
3:mysql-community-client-5.7.23-1.e>>>>>>### [ 75%]
4:mysql-community-server-5.7.23-1.e>>>>>>### [100%]
<5>数据库初始化
[root@imok mysql]# mysqld --initialize --user=mysql
为了保证数据库⽬录为与⽂件的所有者为 mysql 登陆⽤户,如果你是以 root ⾝份运⾏ mysql 服务,需要执⾏下⾯的命令初始化
mysqld --initialize --user=mysql
如果是以 mysql ⾝份运⾏,则可以去掉 --user 选项。
另外 --initialize 选项默认以“安全”模式来初始化,则会为 root ⽤户⽣成⼀个密码并将该密码标记为过期,登陆后你需要设置⼀个新的密码,⽽使⽤ --initialize-insecure 命令则不使⽤安全模式,则不会为 root ⽤户⽣成⼀个密码。
使⽤的 --initialize 初始化的,会⽣成⼀个 root 账户密码,密码在log⽂件⾥,红⾊区域的就是⾃动⽣成的密码
[root@imok mysql]# cat /var/log/mysqld.log
2018-08-02T11:44:44.783409Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-08-02T11:44:45.120708Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-08-02T11:44:45.170790Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-08-02T11:44:45.241814Z 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: 73aed9c6-9649-11e8-ae68-080027cf8d60. 2018-08-02T11:44:45.243701Z 0 [Warning] Gtid table is not ready to be used. Table 'id_executed' cannot be opened.
2018-08-02T11:44:45.244381Z 1 [Note] A temporary password is generated for root@localhost: I,mwy,zgD5U1
<6>启动mysql服务
[root@imok mysql]# systemctl start mysqld.service
<7>登录测试
[root@imok mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.23
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> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.提⽰需要修改密码。
<8>修改密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
Query OK, 0 rows affected (0.00 sec)
再次检查
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '!QAZ2wsx' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.01 sec)
说明安装成功!
远程访问失败!!
解决⽅案:
参考:
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
centos7回root密码
« 上一篇
【passwd】关于更改用户密码
下一篇 »
热门文章
-
利用正则表达式实现文本数据提取与处理
2025-02-08 -
正则表达式零宽断言详解
2025-02-08 -
文本匹配规则
2025-02-08 -
excel中使用正则
2025-02-08 -
1-31正则表达式
2025-02-08 -
anki之高级筛选
2025-02-08 -
BUAA_OO_2021_第一单元总结
2025-02-08 -
insert语句递增写法
2025-02-08 -
sublime text 3在行前插入递增数字序号的方法
2025-02-08 -
字符串只允许数字和英文的正则
2025-02-08 -
powerbuilder 正则表达式
2025-02-08 -
Shell脚本编写的高级技巧利用正则表达式进行字符串匹配
2025-02-08 -
JAVA正则表达式的三种模式:贪婪,勉强和占有的讨论
2025-02-08 -
go regexp匹配规则
2025-02-08 -
oracle regexp_substr 实现原理
2025-02-08 -
基本的元字符 回溯引用和前后查 匹配模式
2025-02-08 -
elasticsearch query dsl正则
2025-02-08 -
oracle sql正则表达式
2025-02-08 -
GA-设置目标
2025-02-08 -
仅匹配全角片假名的正则表达式
2025-02-08
最新文章
-
java正则表达式 选择题
2025-02-12 -
工龄小数点提取
2025-02-08 -
非零金额 正则表达式
2025-02-08 -
提取文本中数字的函数
2025-02-08 -
vue数字相加小数点变长-概述说明以及解释
2025-02-08 -
vue validate 正则验证小数长度
2025-02-08
发表评论