zoukankan      html  css  js  c++  java
  • SUSE 安装mysql

    1.下载mysql rpm包

    在该网站选择相应的包 http://dev.mysql.com/downloads/mysql/5.0.html

    这里选择:MySQL-server-5.6.17-1.sles11.x86_64.rpmMySQL-client-5.6.17-1.sles11.x86_64.rpm

    安装这两个包,执行 rpm -ivh MySQL-server-5.6.17-1.sles11.x86_64.rpm

                              rpm -ivh MySQL-client-5.6.17-1.sles11.x86_64.rpm

    2.启动mysql

    /etc/init.d/mysql start

    3.连接mysql

    1. [root@localhost bin]# ./mysql -uroot -p12345  
    2. ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)  

     

    遇到上面情况怎么办,请按如下步骤操作:

    1、停止mysql服务

    1. [root@localhost bin]# chkconfig --list | grep -i mysql  
    2. mysql           0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭  
    3. [root@localhost bin]# service mysql stop  
    4. Shutting down MySQL                                        [确定]  

    2、用mysqld_safe重启服务

    1. [root@localhost bin]# ./mysqld_safe --user=root --skip-grant-tables --skip-networking &  
    2. [1] 3818  
    3. [root@localhost bin]# 111105 07:30:32 mysqld_safe Logging to '/usr/local/mysql/var/localhost.localdomain.err'.  
    4. 111105 07:30:32 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var  
    5. ./mysql -uroot mysql  
    6. Welcome to the MySQL monitor.  Commands end with ; or g.  
    7. Your MySQL connection id is 1  
    8. Server version: 5.1.48-log Source distribution  
    9.   
    10.   
    11.   
    12.   
    13. Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.  
    14. This software comes with ABSOLUTELY NO WARRANTY. This is free software,  
    15. and you are welcome to modify and redistribute it under the GPL v2 license  
    16.   
    17.   
    18.   
    19.   
    20. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.  


    3、重设密码

    1. mysql> update user set password=password('12345') where user='root' ;  
    2. Query OK, 3 rows affected (0.05 sec)  
    3. Rows matched: 3  Changed: 3  Warnings: 0  
    4.   
    5.   
    6.   
    7.   
    8. mysql> flush privileges;  
    9. Query OK, 0 rows affected (0.00 sec)  
    10.   
    11.   
    12.   
    13.   
    14. mysql> quit  
    15. Bye  


    4、重启服务

    1. [root@localhost bin]#service mysql stop  
    2.   
    3.   
    4. [root@localhost bin]# service mysql start  


    5、再次连接数据库

      1. [root@localhost bin]# ./mysql -uroot -p12345  
      2. Welcome to the MySQL monitor.  Commands end with ; or g.  
      3. Your MySQL connection id is 1  
      4. Server version: 5.1.48-log Source distribution  
      5.   
      6.   
      7.   
      8.   
      9. Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.  
      10. This software comes with ABSOLUTELY NO WARRANTY. This is free software,  
      11. and you are welcome to modify and redistribute it under the GPL v2 license  
      12.   
      13.   
      14.   
      15.   
      16. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. 

     --------------------------------------------------------------------------------------------------

    增加MySQL用户,使之可以远程连接

      格式:grant select on 数据库.* to 用户名@登录主机 identified by "密码"
    1、增加一个用户user_1密码为123,让他可以在任何主机上登录,并对所有数据库有查询、插入、修改、删除的权限。首先用以root用户连入MySQL,然后键入以下命令:

      mysql> grant select,insert,update,delete on *.* to user_1@"%" Identified by "123";
    1增加的用户是十分危险的,如果知道了user_1的密码,那么他就可以在网上的任何一台电脑上登录你的MySQL数据库并对你的数据为所欲为了,解决办法见例2

      例2、增加一个用户user_2密码为123,让此用户只可以在localhost上登录,并可以对数据库aaa进行查询、插入、修改、删除的 操作(localhost指本地主机,即MySQL数据库所在的那台主机),这样用户即使用知道user_2的密码,他也无法从网上直接访问数据库,只能 通过MYSQL主机来操作aaa库。

      mysql>grant select,insert,update,delete on aaa.* to user_2@localhost identified by "123";

      用新增的用户如果登录不了MySQL,在登录时用如下命令:

      mysql -u user_1 -p -h 192.168.113.50 (-h后跟的是要登录主机的ip地址)

  • 相关阅读:
    vue vant 循环picker模块的实现方法
    Element的表单验证规则,清空或填充数据如何避免自动触发
    递归寻找树结构的子节点
    vue源码解析实例(二)---vue 虚拟DOM篇
    vue源码解析实例(一)
    变化侦测篇---Object.create(null)的定义
    vue源码-变化侦测篇(小知识点)
    Vue源码学习-开篇
    position: sticky轻松做出吸顶功能
    自适应图片高度蒙层 css
  • 原文地址:https://www.cnblogs.com/duyy/p/3638786.html
Copyright © 2011-2022 走看看