|NO.Z.00001|——————————|^^ 构建 ^^|——|Mysql.V5.7.35|

一、centos7安装mysql5.7.27
### --- 下载 MySQL yum包

wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm
### --- 安装MySQL源

rpm -Uvh mysql57-community-release-el7-10.noarch.rpm
### --- 安装MySQL服务端,需要等待一些时间

yum install -y mysql-community-server
### --- 启动MySQL

systemctl start mysqld.service
### --- 检查是否启动成功

systemctl status mysqld.service
二、mysql授权
### --- 获取临时密码,MySQL5.7为root用户随机生成了一个密码

grep 'temporary password' /var/log/mysqld.log 
### --- 通过临时密码登录MySQL,进行修改密码操作
### --- 使用临时密码登录后,不能进行其他的操作,否则会报错,这时候我们进行修改密码操作

mysql -uroot -p
### --- 因为MySQL的密码规则需要很复杂,我们一般自己设置的不会设置成这样,所以我们全局修改一下
mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=1;

### --- 这时候我们就可以自己设置想要的密码了
ALTER USER 'root'@'localhost' IDENTIFIED BY 'yourpassword';
### --- 授权其他机器远程登录

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
### --- 开启开机自启动:先退出mysql命令行,然后输入以下命令

systemctl enable mysqld
systemctl daemon-reload
### --- 设置MySQL的字符集为UTF-8,令其支持中文

vim /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
 
[mysql]
default-character-set=utf8
 
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
default-storage-engine=INNODB
character_set_server=utf8
 
symbolic-links=0
 
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
### --- 重启一下MySQL,令配置生效

systemctl restart mysqld
### --- 防火墙开放3306端口

firewall-cmd --state
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
三、卸载mysql
### --- 卸载MySQL仓库
### --- 一开始的时候我们安装的yum,每次yum操作都会更新一次,耗费时间,我们把他卸载掉

rpm -qa | grep mysql
yum -y remove mysql57-community-release-el7-10.noarch
### --- 数据库的操作
### --- 查看mysql是否启动:service mysqld status

~~~		启动mysql:service mysqld start
~~~		停止mysql:service mysqld stop
~~~		重启mysql:service mysqld restart
### --- 查看临时密码:grep password /var/log/mysqld.log

附录一:
### --- 辅助资料:

https://www.cnblogs.com/jinghuyue/p/11565564.html

 
 
 
 
 
 
 
 
 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 

 

posted on   yanqi_vip  阅读(19)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示