欢迎投稿

今日深度:

CenOS-6.x~7.x修改mysql默认root密码,cenos-6.x7.x

CenOS-6.x~7.x修改mysql默认root密码,cenos-6.x7.x


1.   卸载mariadb(mysql已经走向收费,因此mariadb作为mysql的一个分支应运而生),已经安装mariadb的情况下再安装mysql会因为冲突而安装失败。因此先卸载mariadb

执行如下命令,查看mariadb以及相关的程序安装情况:rpm-qa | grep mariadb

使用rpm命令卸载所有的程序(出现在” rpm-qa | grep mariadb”执行结果中的)
rpm -e mariadb-libs-5.5.37-1.el7_0.x86_64

但是也许rpm会报告因为这个包被其他包依赖,其他包的存在导致无法被卸载,那么就强制卸载
rpm -e --nodeps mariadb-libs-5.5.37-1.el7_0.x86_64

 

2.    下载mysql-community-release-el7-7.noarch.rpm

3.    rpm 安装此软件源

rpm –ivh mysql-community-release-el7-7.noarch.rpm

4.    yum install mysql-server

5.    修改mysql配置文件,允许不输入密码登录mysql(在mysqld这个section添加skip-grant-tables这一行)

[mysqld]

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

skip-grant-tables

6.    启动mysql

Service mysqld start

7.    连接mysql, 修改密码

[root@k2~]# mysql

Welcometo the MySQL monitor.  Commands end with; or \g.

YourMySQL connection id is 5

Serverversion: 5.7.19 MySQL Community Server (GPL)

 

Copyright(c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

 

Oracle isa registered trademark of Oracle Corporation and/or its

affiliates.Other names may be trademarks of their respective

owners.

 

Type'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

mysql>use mysql;

Readingtable information for completion of table and column names

You canturn off this feature to get a quicker startup with -A

 

Databasechanged

mysql>UPDATE user SET authentication_string=password("mysql.passwd") WHEREUser='root';

Query OK,0 rows affected, 1 warning (0.00 sec)

Rows matched: 1 Changed: 0  Warnings: 1

mysql>flush privileges;

Query OK,0 rows affected (0.00 sec)

 

mysql>quit

Bye

8. 这时候算完了吗?no no no~!要把my.cnf修改回来(第五步里加上的skip-grant-tables这一行去掉)

[mysqld]

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock



References:

1.    http://www.linuxidc.com/Linux/2016-03/129683.htm

2.    http://www.cnblogs.com/allenblogs/archive/2010/08/12/1798247.html

3.    http://www.cnblogs.com/daizhuacai/archive/2013/01/17/2865138.html


如果您要使用该文章,请注明出处,附带上本文地址。

www.htsjk.Com true http://www.htsjk.com/mariadb/25933.html NewsArticle CenOS-6.x~7.x修改mysql默认root密码,cenos-6.x7.x 1.    卸载 mariadb(mysql 已经走向收费,因此 mariadb 作为 mysql 的一个分支应运而生 ) ,已经安装 mariadb 的情况下再安装 mysql 会因为冲突而安装失...
相关文章
    暂无相关文章
评论暂时关闭