1、下载Mysql安装所需的rpm包

概述:

http://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-server-5.6.21-1.linux_glibc2.5.x86_64.rpmhttp://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-client-5.6.21-1.linux_glibc2.5.x86_64.rpmhttp://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-devel-5.6.21-1.linux_glibc2.5.x86_64.rpm

本文不再对MySQL的语法进行讲解和说明,想了解或熟悉的朋友请自行百度或Google学习。本文主要是针对MySQL除语法之外的总结,希望能够也能帮助到你。

 

1.CentOS6.x下MySQL忘记root密码解决方法

2、安装

Ⅰ. 修改MySQL的登录设置

[root@Luxh-01 softs]# rpm -ivh MySQL-server-5.6.21-1.linux_glibc2.5.x86_64.rpm 



[root@Luxh-01 softs]# rpm -ivh MySQL-client-5.6.21-1.linux_glibc2.5.x86_64.rpm



[root@Luxh-01 softs]# rpm -ivh MySQL-devel-5.6.21-1.linux_glibc2.5.x86_64.rpm

 # vim /etc/my.cnf

  安装过程中,Mysql会成一个随机密码给root用户,密码存储在 /root/.mysql_secret

在[mysqld]段中加上一句:skip-grant-tables

  MySQL安装目录信息:

Ⅱ. 重启服务

Directory Contents of Directory
/usr/bin Client programs and scripts
/usr/sbin The mysqld server
/var/lib/mysql Log files, databases
/usr/share/info Manual in Info format
/usr/share/man Unix manual pages
/usr/include/mysql Include (header) files
/usr/lib/mysql Libraries
/usr/share/mysql Miscellaneous support files, including error messages, character set files, sample configuration files, SQL for database installation
/usr/share/sql-bench Benchmarks

# service mysqld restart

 

Ⅲ. 登录Mysql,修改密码信息 # mysql
mysql> USE mysql;
mysql> UPDATE user SET Password=password (‘new-password’) WHERE
User=’root’;
mysql> flush privileges;
mysql> quit

3、启动MySQL:

Ⅳ. 还原Mysql的登录设置

[root@Luxh-01 ~]# service mysql startStarting MySQL...                     [确定][root@Luxh-01 ~]# service mysql statusMySQL running (3270)                    [确定]

# vim /etc/my.cnf

 

将[mysqld]的段中加上的skip-grant-tables注释或是删除

4、登录MySQL

Ⅴ. 重启服务

[root@Luxh-01 ~]# mysql -uroot -p

 # service mysqld restart

  输入安装时生成的随机密码即可登入到MySQL的命令行界面

图片 1

Author

发表评论

电子邮件地址不会被公开。 必填项已用*标注