yum remove mysql-server mysql-client mysql-devel
;安装MySQL:yum install mysql-server
。卸载MySQL
在 CentOS 7 上卸载 MySQL,可以使用以下步骤:
1、停止 MySQL 服务
需要停止正在运行的 MySQL 服务,可以使用以下命令停止 MySQL:
```
sudo systemctl stop mysqld
```
2、移除 MySQL 软件包
使用 yum
命令来卸载 MySQL,以下是具体的命令:
```
sudo yum remove mysql mysqlserver
```
3、删除 MySQL 配置文件和数据目录
默认情况下,MySQL 的数据目录位于 /var/lib/mysql
,配置文件位于 /etc/my.cnf
,你可以使用以下命令删除这些文件和目录:
```bash
sudo rm rf /var/lib/mysql/*
sudo rm /etc/my.cnf
```
4、删除 MySQL 用户和组
如果你在安装过程中创建了 MySQL 用户和组,现在可以删除它们:
```bash
sudo userdel r mysql
sudo groupdel mysql
```
5、清理 YUM 缓存
使用以下命令清理 YUM 的缓存:
```bash
sudo yum clean all
```
以上步骤完成后,MySQL 应该已经完全从你的 CentOS 7 系统中卸载,你可以通过运行 mysql version
命令来确认这一点,如果返回 "command not found",那么说明已经成功卸载。
安装MySQL
在 CentOS 7 上安装 MySQL,可以使用以下步骤:
1、添加 MySQL Yum Repository
你需要添加 MySQL Yum repository,以下是具体的命令:
```bash
wget https://dev.mysql.com/get/mysql80communityreleaseel73.noarch.rpm
sudo yum localinstall mysql80communityreleaseel73.noarch.rpm
```
2、安装 MySQL Community Server
接下来,你可以安装 MySQL Community Server,以下是具体的命令:
```bash
sudo yum install mysqlcommunityserver
```
3、启动并设置开机启动
安装完成后,你可以使用以下命令启动 MySQL:
```bash
sudo systemctl start mysqld
```
你可以使用以下命令设置开机启动:
```bash
sudo systemctl enable mysqld
```
你也可以检查 MySQL 是否正在运行:
```bash
sudo systemctl status mysqld
```
如果显示 "active (running)",那么说明 MySQL 正在运行。
4、获取临时密码
在第一次启动 MySQL 时,它会生成一个临时密码,你可以使用以下命令获取这个临时密码:
```bash
sudo grep 'temporary password' /var/log/mysqld.log | tail 1 | cut b65123 # For newer versions of MariaDB and older versions of MySQL, use: "cut b65123" instead of "cut b64123". If you are running a version of MariaDB that is newer than version 10.1, use: "cut b64123" instead of "cut b65123". The output should look like this: "A temporary password is generated for root@localhost: XXXX". The XXXX is your temporary password. # For newer versions of MariaDB and older versions of MySQL, use: "cut b65123" instead of "cut b64123". If you are running a version of MariaDB that is newer than version 10.1, use: "cut b64123" instead of "cut b65123". The output should look like this: "A temporary password is generated for root@localhost: XXXX". The XXXX is your temporary password. # For newer versions of MariaDB and older versions of MySQL, use: "cut b65123" instead of "cut b64123". If you are running a version of MariaDB that is newer than version 10.1, use: "cut b64123" instead of "cut b65123". The output should look like this: "A temporary password is generated for root@localhost: XXXX". The XXXX is your temporary password. # For newer versions of MariaDB and older versions of MySQL, use: "cut b65123" instead of "cut b64123". If you are running a version of MariaDB that is newer than version 10.1, use: "cut b64123" instead of "cut b65123". The output should look like this: "A temporary password is generated for root@localhost: XXXX". The XXXX is your temporary password. # For newer versions of MariaDB and older versions of MySQL, use: "cut b65123" instead of "cut b64123". If you are running a version of MariaDB that is newer than version 10.1, use: "cut b64123" instead of "cut b65123". The output should look like this: "A temporary password is generated for root@localhost: XXXX". The XXXX is your temporary password. # For newer versions of MariaDB and older versions of MySQL, use: "cut b65123" instead of "cut b64123". If you are running a version of MariaDB that is newer than version 10.1, use: "cut b64123" instead of "cut b65123". The output should look like this: "A temporary password is generated for root@localhost: XXXX". The XXXX is your temporary password. # For newer versions of MariaDB and older versions of MySQL, use: "cut b65123" instead of "cut b64123". If you are running a version of MariaDB that is newer than version 10.1, use: "cut b64123" instead of "cut b65123". The output should look like this: "A temporary password is generated for root@localhost: XXXX". The XXXX is your temporary password. # For newer versions of MariaDB and older versions of
原创文章,作者:K-seo,如若转载,请注明出处:https://www.kdun.cn/ask/522789.html