酒店网站建设价格,宁波专业的网站建设,上海到北京顺丰快递要多久,wordpress模板赚钱说明#xff1a;
安装与卸载中#xff0c;用户全部切换成为root#xff0c;⼀旦安装#xff0c;普通用户就能使用。初期练习#xff0c;mysql不进行用户管理#xff0c;全部使⽤root进⾏#xff0c;尽快适应mysql语句#xff0c;后⾯学了用户管理#xff0c;在考虑新…说明
安装与卸载中用户全部切换成为root⼀旦安装普通用户就能使用。初期练习mysql不进行用户管理全部使⽤root进⾏尽快适应mysql语句后⾯学了用户管理在考虑新建普通用户。
1.卸载不要的环境
//1.切换到超级用户
su -
//2.查看云服务器检查是否存在 mariadb 数据库内置的MySQL数据库有则强制删除
rpm -qa | grep mysql #检查是否安装过MySQL
ps ajx | grep mariadb
//3.若有则停止服务
systemctl stop mysqld
//停止完成
13134 14976 14975 13134 pts/0 14975 S 1005 0:00 grep --colorauto
mariadb2.检查系统安装包
rpm -qa | grep mariadb或者rpm -qa | grep mysql
//下⾯是打印出来的mysql的样例
[rootbite-alicloud mysql]# rpm -qa | grep mysql
mysql-community-common-5.7.41-1.el7.x86_64
mysql-community-server-5.7.41-1.el7.x86_64
mysql57-community-release-el7-11.noarch
mysql-community-client-5.7.41-1.el7.x86_64
mysql-community-libs-5.7.41-1.el7.x86_643.卸载这些默认安装包
rpm -qa | grep mysql | xargs yum -y remove检查是否卸载成功
ls /etc/my.cnf
ls: cannot access /etc/my.cnf: No such file or directory//卸载成功4.获取mysql官方yum源
获取mysql官⽅yum源 http://repo.mysql.com/注意最好安装和⾃⼰系统⼀致的mysql版本否则可能会存在软件兼容性问题查看⾃⼰的系统版本
[rootVM-0-2-centos ~] # cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)可以进⼊ http://repo.mysql.com/ 找⼀下和⾃⼰版本⼀致的资源 下载到你的本地然后上传到你的Linux服务器
5.安装mysql yum源对⽐前后yum源
我这里直接提供安装命令你们注意看下你们的系统版本是否和我一致
curl -O https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm查看你本地的yum源 [我的和你的肯定不同但是没有mysql相关的yum源] ls /etc/yum.repos.d/ -al下载成功
# lltotal 28
-rw-r--r-- 1 root root 25680 Jul 20 10:45 mysql57-community-release-el7-11.noarch.rpm安装
rpm -Uvh mysql57-community-release-el7-11.noarch.rpm安装后,再查看本地yum源,就会出现两个mysql的文件了
ls /etc/yum.repos.d/ -al6.看看能不能正常⼯作
yum list |grep mysqlRepository epel is listed more than once in the configuration
mysql57-community-release.noarch el7-10 installed
akonadi-mysql.x86_64 1.9.2-4.el7 base
anope-mysql.x86_64 2.0.9-3.el7 epel
apr-util-mysql.x86_64 1.5.2-6.el7 base
calligra-kexi-driver-mysql.x86_64 2.9.10-2.el7 epel
collectd-mysql.x86_64 5.8.1-1.el7 epel
dmlite-plugins-mysql.x86_64 1.14.2-1.el7 epel
dovecot-mysql.x86_64 1:2.2.36-8.el7 base安装完毕之后我们就可以把安装包删掉了。
7. 安装mysql服务
yum install -y mysql-community-serverLoaded plugins: aliases, auto-update-debuginfo, fastestmirror, protectbase
Repository epel is listed more than once in the configuration
...
Installing : mysql-community-common-5.7.33-1.el7.x86_64 #公共模块
Installing : mysql-community-libs-5.7.33-1.el7.x86_64 #库
Installing : mysql-community-client-5.7.33-1.el7.x86_64 #客⼾端
Installing : mysql-community-server-5.7.33-1.el7.x86_64 #服务器
... #安装了服务和客⼾端安装mysql服务常见问题
安装遇到秘钥过期的问题
Failing package is: mysql-community-client-5.7.39-1.el7.x86_64
GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql解决⽅案再命令行输入以下语句之后重新安装mysql服务
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
8.查看配置⽂件和数据存储位置 9. 启动服务并检查MySQL运行状态
systemctl start mysqld.service查看启动服务
10.登陆方法一【不行就下一个】
获取临时root密码:
sudo grep temporary password /var/log/mysqld.log//若是root用户就不用带sudo使⽤临时密码登录:
mysql -uroot -p在创建数据库或数据表之前要先用一下命令修改 root 用户的密码
ALTER USER rootlocalhost IDENTIFIED BY 新密码;安全强度默认为中即1要求必须包含 数字、符号、⼤⼩写字⺟⻓度⾄少为8位
11.登陆方法二【不行就下一个】
如果你安装的最新的mysql没有所谓的临时密码root默认没有密码 试着直接client登陆⼀下
12.登陆方式三【应该行了吧】 vim /etc/my.cnf //打开mysql配置⽂件在[mysqld]最后⼀栏配置(不知道是什么就放在配置⽂件最后) 加⼊: skip-grant-tables 选项, 并保存退出
systemctl restart mysqld // 重启mysql服务mysql -uroot//登录13. 配置my.cnf
配置⼀下my.conf,主要是数据库客⼾端和服务器的编码格式 加以下配置
port3306 //绑定指定的端口号
character-set-serverutf8
default-storage-engineinnodb//默认的存储引擎datadir/var/lib/mysql//建表建库数据所在的路径
socket/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links0
log-error/var/log/mysqld.log//错误日志
pid-file/var/run/mysqld/mysqld.pid配置完毕重启mysql即可
systemctl restart mysqld // 重启mysql服务14.设置开机启动[可以不设]
#开启开机⾃启动
systemctl enable mysqld
systemctl daemon-reload15.退出mysql
Ctrlz
16.常见问题
mysql 已经配置了客⼾端服务器utf8编码但是⽆法输⼊中⽂ 确保您在终端命令⾏中可以输⼊中⽂
env |grep LANG
LANGen_US.utf8安装遇到秘钥过期的问题
Failing package is: mysql-community-client-5.7.39-1.el7.x86_64
GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
解决⽅案
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022