wordpress书店主题,seo搜索优化排名,国外网络推广哪家公司好,网页游戏制作培训目录 MySql 在 CentOS 7 环境下安装。
说明#xff1a;
1.卸载不要的环境
2.配置 mysql 官方 yum 源
3.开始安装
4.启动 mysql
5.mysql 登录
6.配置 mysql
7. 设置开机启动 MySql 在 CentOS 7 环境下安装。
说明#xff1a; 在安装与卸载中#xff0c;用户切换成 r…目录 MySql 在 CentOS 7 环境下安装。
说明
1.卸载不要的环境
2.配置 mysql 官方 yum 源
3.开始安装
4.启动 mysql
5.mysql 登录
6.配置 mysql
7. 设置开机启动 MySql 在 CentOS 7 环境下安装。
说明 在安装与卸载中用户切换成 root 一旦安装普通用户能使用 1.卸载不要的环境
1. 先检查是否有这些环境
[rootslave0 ~]# ps axj | grep mysql3446 3541 3540 3392 pts/0 3540 S 0 0:00 grep --colorauto mysql
[rootslave0 ~]# ps axj | grep mariadb3446 3584 3583 3392 pts/0 3583 S 0 0:00 grep --colorauto mariadb
上面的 mariadb 其实就是 mysql。
上面没有查到有 mysql 的服务如果有的话就删掉。
虽然这里没有但是还是演示一下如何删除。
这里删除的时候需要把用户切换成 root 用户否则无法卸载。
2. 先关闭 mysql 服务
rootslave0 ~]# systemctl stop mysqld
我们在 yum 上获得的 mysql 都是 .rpm 的。所以我们可以使用 rmp 来查看 yum 上获得的 mysql 的安装包查到后卸载掉。
3. 查询 yum 获得的 mysql
[rootslave0 ~]# rpm -qa | grep mysql
mysql-3.1.0-12.el7.x86_64
4.查询到后删除因为是 yum 安装所以使用 yum remove
删除的时候可以一个一个删除也可以批量化删除。
[rootslave0 ~]# rpm -qa | grep mysql | xargs yum -y remove
这里使用 xargs 就是将查询到的数据按照命令行参数的形式经过管道传到 yum remove 里由于删除的时候要确认所以我们不想确认我们可以带 -y 选项。
下一步我们就继续查询一下如果没有 mysql 的安装包和对应的进程就可以了。
然后我们在卸载掉我们有关之前安装 mysql 剩余的配置环境
5. 在 /etc/ 目录下
[rootslave0 etc]# cd /etc/
[rootslave0 etc]# ls | grep my.cnf | xargs rm -rf
[rootslave0 etc]# ls | grep my.cnf
[rootslave0 etc]#
上面就就这样就卸载干净了 2.配置 mysql 官方 yum 源
1. 获取 mysql 官方 yum 源 http://repo.mysql.com/
2. 注意安装的和自己系统一直的版本否则可能出现软件兼容问题。
3. 检查自己系统版本。
[rootslave0 etc]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
我这里是 7.5 的版本所以尽量找 mysql
IMG SRC/icons/generic.gif ALT[FILE] A HREFmysql57-community-release-el7.rpmmysql57-community-release-el7.rpm/A 27-Apr-2017 10:45 25k
由于我上面没有找到与自己匹配的所以就挑选这个。
当下载好后我们会下载到本地然后我们在到 Linux 上建一个 MySql 的路径然后我们把刚刚下载好的 MySql 的上传上来。
[rootslave0 /]# cd MySql/
[rootslave0 MySql]# rz
[rootslave0 MySql]# ll
总用量 28
-rw-r--r--. 1 root root 25680 8月 20 12:21 mysql57-community-release-el7.rpm
这里就上传上来了。
我们要先查一下我们默认支持的 yum 源。
[rootslave0 MySql]# ls /etc/yum.repos.d/ -l
总用量 40
-rw-r--r--. 1 root root 1664 4月 29 2018 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 4月 29 2018 CentOS-CR.repo
-rw-r--r--. 1 root root 649 4月 29 2018 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 4月 29 2018 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 4月 29 2018 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 4月 29 2018 CentOS-Sources.repo
-rw-r--r--. 1 root root 4768 4月 29 2018 CentOS-Vault.repo
-rw-r--r--. 1 root root 1358 9月 5 2021 epel.repo
-rw-r--r--. 1 root root 1457 9月 5 2021 epel-testing.repo
我们这里面没有 mysql 的所以我们还要做 yum 源 安装。
安装 yum 源
[rootslave0 MySql]# rpm -ivh mysql57-community-release-el7.rpm
警告mysql57-community-release-el7.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...1:mysql57-community-release-el7-11 ################################# [100%]
安装好后我们继续查一下 yum 源
[rootslave0 MySql]# ls -l /etc/yum.repos.d/
总用量 48
-rw-r--r--. 1 root root 1664 4月 29 2018 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 4月 29 2018 CentOS-CR.repo
-rw-r--r--. 1 root root 649 4月 29 2018 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 4月 29 2018 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 4月 29 2018 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 4月 29 2018 CentOS-Sources.repo
-rw-r--r--. 1 root root 4768 4月 29 2018 CentOS-Vault.repo
-rw-r--r--. 1 root root 1358 9月 5 2021 epel.repo
-rw-r--r--. 1 root root 1457 9月 5 2021 epel-testing.repo
-rw-r--r--. 1 root root 1838 4月 27 2017 mysql-community.repo
-rw-r--r--. 1 root root 1885 4月 27 2017 mysql-community-source.repo这下就有了。
yum 源安装好后我们 yum list 就能查到我们想要的 mysql 了。
3.开始安装
前面的步骤都完成后我们就可以一键安装 mysql 了。
yum install -y mysql-community-server如果在安装中出现错误可能就是下面的错误。
1. 安装遇到密钥过期的问题
2. Failing package is: mysql-community-client-5.7.39-1.el7.x86_64
3. GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
4.
5. 解决方案
6. rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022安装成功后要存在 /etc/my.cnf 的文件。
还要能查到一个 mysqld
[rootslave0 MySql]# which mysql
/usr/bin/mysql还要能查到 mysql 的客户端
[rootslave0 MySql]# which mysqld
/usr/sbin/mysqld启动 mysql 的服务器的时候一般启动的时候需要 root 来启动。 4.启动 mysql
[rootslave0 MySql]# systemctl start mysqld
[rootslave0 MySql]# ps axj | grep mysqld1 5888 5887 5887 ? -1 Sl 27 0:00 /usr/sbin/mysqld --daemonize --pid-file/var/run/mysqld/mysqld.pid4465 5921 5920 4465 pts/1 5920 S 0 0:00 grep --colorauto mysqld
然后查一下是否有 mysqld 的一个程序启动。 5.mysql 登录
mysql 的登陆方法很多下面说一个比较通用的方法
1. 打开 mysql 的配置文件 /etc/my.cnf
2. 在最后一行添加 skip-grant-tables
[rootslave0 MySql]# vim /etc/my.cnf
[rootslave0 MySql]# cat /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# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links0log-error/var/log/mysqld.log
pid-file/var/run/mysqld/mysqld.pid
skip-grant-tables配置完成后我们重启一下 mysql 的服务就可以了然后直接登录
mysql -u root -p
直接回车就可以mysql show databases;
--------------------
| Database |
--------------------
| information_schema |
| mysql |
| performance_schema |
| sys |
--------------------
4 rows in set (0.00 sec)然后我们 show databases 查看一下数据库就可以了。 6.配置 mysql
1 配置mysql 主要是配置 mysql 的编码格式源
# 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# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links0log-error/var/log/mysqld.log
pid-file/var/run/mysqld/mysqld.pid
skip-grant-tables# 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 2Mport3306
character-set-serverutf8
default-storage-engineinnodbdatadir/var/lib/mysql
socket/var/lib/mysql/mysql.sock# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links0log-error/var/log/mysqld.log
pid-file/var/run/mysqld/mysqld.pid
skip-grant-tables加了三行
等配置文件修改完毕后我们还需要重启 mysql 服务
因为 mysql 的默认端口号是 3306 所以我们自己使用的话不建议修改为其他的端口号。 7. 设置开机启动
[rootslave0 MySql]# systemctl enable mysqld
[rootslave0 MySql]# systemctl daemon-reload如果是服务器的话那么其实设置不设置都一样如果是虚拟机的话那么可以设置一下。