posts - 325,  comments - 25,  trackbacks - 0

Red Hat Enterprise Linux 6 / Oracle Linux 6 (Architecture Independent), RPM Package


9.0K
(mysql57-community-release-el6-9.noarch.rpm)

2. 下载并安装Mysql的yum仓库

下载Mysql的yum仓库

http://dev.mysql.com/downloads/repo/yum/

然后安装一下这个仓库列表

$ sudo yum localinstall mysql-community-release-el6-5.noarch.rpm  

3. 搜索可安装的mysql版本

执行这个命令后就能看到可安装的mysql:

# yum repolist enabled | grep "mysql.*-community.*" 

如果我们是要安装最新的版本,那么可以直接执行

# sudo yum install mysql-community-server 

如果我们要选择版本,可以先执行下面这个命令查看一下有哪些版本:

# yum repolist all | grep mysql 

如果要选择版本的话,有两种方式,一种是使用命令来

$ sudo yum-config-manager --disable mysql56-community $ sudo yum-config-manager --enable mysql57-community-dmr 

这个命令就是在仓库中启用5.7版本的,禁用5.6版本子仓库
或者编辑/etc/yum.repos.d/mysql-community.repo文件

# Enable to use MySQL 5.6 [mysql56-community] name=MySQL 5.6 Community Server baseurl=//repo.mysql.com/yum/mysql-5.6-community/el/5/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql  

enabled=0表示禁用
比如要安装5.7版本的mysql,要确定5.6的enabled=0,5.7的enabled=1,一次保证只启用一个子仓库

# Note: MySQL 5.7 is currently in development. For use at your own risk. # Please read with sub pages: https://dev.mysql.com/doc/relnotes/mysql/5.7/en/ [mysql57-community-dmr] name=MySQL 5.7 Community Server Development Milestone Release baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql 

然后我们又可以愉快的安装mysql了

$ sudo yum install mysql-community-server 

安装完成后我们启动mysql

$ sudo service mysqld start 

查看mysql状态

$ sudo service mysqld status 

启动mysql服务并初始化:

# /etc/init.d/mysqld start Initializing MySQL database:  PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands:  /usr/bin/mysqladmin -u root password 'new-password' /usr/bin/mysqladmin -u root -h iZ94vana2fdZ password 'new-password'  Alternatively you can run: /usr/bin/mysql_secure_installation  which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers.  See the manual for more instructions.  Please report any problems at http://bugs.mysql.com/  [ OK ] Starting mysqld: [ OK ] 

4. 相关命令

启动mysql服务

# service mysqld start 

重启mysql服务

# service mysqld restart 

停止mysql服务

# service mysqld stop 


  1. Stop the service/daemon of mysql running

    [root ~]# service mysql stop    mysql stop/waiting 
  2. Start mysql without any privileges using the following option; This option is used to boot up and do not use the privilege system of MySQL.

    [root ~]# mysqld_safe --skip-grant-tables & 

At this moment, the terminal will seem to halt. Let that be, and use new terminal for next steps.

  1. enter the mysql command prompt

    [root ~]# mysql -u root mysql>  
  2. Fix the permission setting of the root user ;

    mysql> use mysql; Database changed mysql> select * from  user; Empty set (0.00 sec) mysql> truncate table user; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.01 sec) mysql> grant all privileges on *.* to root@localhost identified by 'YourNewPassword' with grant option; Query OK, 0 rows affected (0.01 sec) 

*if you don`t want any password or rather an empty password

    mysql> grant all privileges on *.* to root@localhost identified by '' with grant option;     Query OK, 0 rows affected (0.01 sec)*     mysql> flush privileges;     Query OK, 0 rows affected (0.00 sec) 

Confirm the results:

    mysql> select host, user from user; +-----------+------+ | host      | user | +-----------+------+ | localhost | root | +-----------+------+ 1 row in set (0.00 sec) 
  1. Exit the shell and restart mysql in normal mode.

    mysql> quit; [root ~]# kill -KILL [PID of mysqld_safe] [root ~]# kill -KILL [PID of mysqld] [root ~]# service mysql start 
  2. Now you can successfully login as root user with the password you set

     [root ~]# mysql -u root -pYourNewPassword   mysql> 


posted on 2016-09-27 16:55 长春语林科技 阅读(405) 评论(0)  编辑  收藏 所属分类: mysql

只有注册用户登录后才能发表评论。


网站导航:
 
<2016年9月>
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678

 

长春语林科技欢迎您!

常用链接

留言簿(6)

随笔分类

随笔档案

文章分类

文章档案

相册

收藏夹

搜索

  •  

最新评论

阅读排行榜

评论排行榜