当前位置:网站首页>Centos7安装mysql
Centos7安装mysql
2022-04-22 21:53:00 【qnbk】
安装MySql
1、先需要查看系统当中有没有安装mariadb
mariadb和mysql同源
ps ajx |grep mariadb
2、把mariadb.service停掉
systemctl stop mariadb.service
3、检测是否被停掉
ps axj |grep mariadb

4、查看mariadb/mysql安装的rpm包
rpm -qa | grep mariadb
rpm -qa | grep mysql

5、卸载显示出来的mariadb/mysql安装包
sudo yum remove mariadb
备份/etc/my.cnf,备份/var/lib/mysql数据
6、安装
获取mysql官方yum源 :http://repo.mysql.com/
wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm

对比前后yum源
ls /etc/yum.repos.d/ -al

安装yum源
sudo rpm -Uvh mysql57-community-release-el7-10.noarch.rpm

对比前后yum源
ls /etc/yum.repos.d/ -al

查看能不能正常工作
yum list |grep mysql
安装mysql服务
sudo yum install -y mysql-community-server
如果显示安装失败需要加上 --nogpgcheck

sudo yum install -y mysql-community-server --nogpgcheck

查看配置文件
ls /etc/my.cnf
sudo ls /var/lib/mysql
启动服务
systemctl start mysqld.service
(停止服务:systemctl stop mysqld)
查看启动服务
ps axj |grep mysqld

sudo ls -al /var/lib/mysql
7、密码
获取临时root密码
sudo grep 'temporary password' /var/log/mysqld.log

使用临时root 密码
mysql -uroot -p

判断修改密码时候新密码是否符合当前的策略,不满足报错,不让修改,Mysql的密码级别有三种,0级别,1级别,2级别 0级别允许是纯数字,1级别必须包含数字和字母,2级别必须数字,大小写字母都包含。
次操作密码设置为最低级别:
set global validate_password_policy=0;
设置密码最小长度
set global validate_password_length=1;

修改本地密码,暂不授权远端登录
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
FLUSH PRIVILEGES;

开启开机自启动
systemctl enable mysqld
systemctl daemon-reload
8、配置 /etc/my.cnf
主要是数据库客户端和服务器的编码格式
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
port=3306
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
character-set-server=utf8
default-storage-engine=innodb
9、确保终端命令行中可以输入中文
mysql 已经配置了客户端服务器utf8编码,但是无法输入中文
env |grep LANG

版权声明
本文为[qnbk]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_53946312/article/details/124290261
边栏推荐
- 2.58-编写程序is-little-endian,当在小端法机器上编译和运行时返回1,在大端法机器上编译和运行时则返回0。这个程序应该可以运行在任何机器上,无论机器的字长是多少。
- PHP wechat refund certificate
- PHP one-dimensional array de duplication
- IPO of China first science and Technology Shenzhen Stock Exchange: another listed enterprise was born in Hubei with a market value of 8.3 billion
- 4 / 21 Kunming supplementary questions + mathematics
- muduo源码分析之Buffer
- Rpcx source code learning - client side
- Leetcode 04 Median of Two Sorted Arrays
- 0基础UnityURP渲染管线之阴影ShadowCaster-ShadowMask-Map傻傻分不清楚(代码向)
- 如何做一款成功的开源项目
猜你喜欢

2.55-在你能够访问的不同机器上,使用show_bytes(文件show_bytes.c)编译并运行示例代码。确定这些机器使用的字节顺序。

Youqilin 22.04 lts version is officially released | ukui 3.1 opens a new experience!

Sign up to open QKE container engine hosting version and container ecological Conference!
![[Istio是什么?] 还不知道你就out了,一文40分钟快速理解](/img/c4/07d319932bddf2eede47bd2078f777.png)
[Istio是什么?] 还不知道你就out了,一文40分钟快速理解

优麒麟 22.04 LTS 版本正式发布 | UKUI 3.1开启全新体验!

Flex layout

Series interpretation of smc-r (II): smc-r communication technology integrating TCP and RDMA

Preprocessing is the process of a program

资源打包关系依赖树

Transport layer - overview of transport layer (1)
随机推荐
Extended practice of chrome devtools inspector
HMS Core Discovery第14期回顾长文|纵享丝滑剪辑,释放视频创作力
Basic practice of C language (001-1)
资源打包关系依赖树
396. 旋转函数 / 剑指 Offer II 013. 二维子矩阵的和
Metawork: please, this remote pairing programming is cool!
系列解读 SMC-R (二):融合 TCP 与 RDMA 的 SMC-R 通信 | 龙蜥技术
Mathematics - Bezier curve
LeetCode-238-除自身以外数组的乘积
Want to day browser: recommend several easy-to-use desktop browsers
Secyun assisted the "SaaS cloud management platform solution based on pseudo application integration framework" released by CETC 32
Best buy website EDI test process
MetaWork:拜托,这样远程结对编程超酷的!
Characteristics of Vickers Vickers proportional valve
JD side: how can a child thread get the value of the parent thread ThreadLocal? I got...
2.60-假设我们将一个w位的字中的字节从0(最低位)到w/8- 1(最高位)编号。写出下面C函数的代码,它会返回一个无符号值,其中参数x的字节i被替换成字节b。
中缀转后缀表达式(逆波兰式) 转 前缀表达式(波兰式)
Wechat applet - day 4
如何做一款成功的开源项目
TS经典类型体操:联合类型如何转为转交叉类型?需要知道三个点:分配律、逆变位置、逆变和协变