zoukankan      html  css  js  c++  java
  • Linux安装MySql

    本文记录Linux安装MySql过程。

    环境:OS:Centos 6.5 x64 & MySql 5.1 x64

    1、系统检查

    检查是否已经安装MySql数据库。

    [root@master ~]# rpm -qa | grep mysql

    如果有安装,先卸载已经安装的MySql数据库。

    [root@master ~]# rpm -e mysql  //普通删除模式
    [root@master ~]# rpm -e --nodeps mysql  //强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除

    2、安装数据库

    [root@master ~]# yum install -y mysql-server mysql mysql-devel

    查看安装情况

    [root@master ~]# rpm -qi mysql-server
    Name        : mysql-server                 Relocations: (not relocatable)
    Version     : 5.1.73                            Vendor: CentOS
    Release     : 3.el6_5                       Build Date: 2014年02月13日 星期四 03时42分39秒
    Install Date: 2014年04月17日 星期四 19时38分28秒      Build Host: c6b9.bsys.dev.centos.org
    Group       : Applications/Databases        Source RPM: mysql-5.1.73-3.el6_5.src.rpm
    Size        : 25882723                         License: GPLv2 with exceptions
    Signature   : RSA/SHA1, 2014年02月13日 星期四 03时48分08秒, Key ID 0946fca2c105b9de
    Packager    : CentOS BuildSystem <http://bugs.centos.org>
    URL         : http://www.mysql.com
    Summary     : The MySQL server and related files
    Description :
    MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
    client/server implementation consisting of a server daemon (mysqld)
    and many different client programs and libraries. This package contains
    the MySQL server and some accompanying files and directories.

    3、管理数据库

    启动数据库

    [root@master ~]# service mysqld start
    初始化 MySQL 数据库: Installing MySQL system tables...
    OK
    Filling help tables...
    OK
    
    To start mysqld at boot time you have to copy
    support-files/mysql.server to the right place for your system
    
    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 master 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.
    
    You can start the MySQL daemon with:
    cd /usr ; /usr/bin/mysqld_safe &
    
    You can test the MySQL daemon with mysql-test-run.pl
    cd /usr/mysql-test ; perl mysql-test-run.pl
    
    Please report any problems with the /usr/bin/mysqlbug script!
    
    [确定]
    正在启动 mysqld: [确定]

    为MySql的root用户设置密码,初始没有密码。

    [root@master ~]# mysqladmin -u root password 'mysql'

    登陆数据库

    [root@master ~]# mysql -u root -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 5
    Server version: 5.1.73 Source distribution
    
    Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a 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> insert into mysql.user(Host,User,Password) values("localhost","hive",password("hive"));
    Query OK, 1 row affected, 3 warnings (0.01 sec)

    刷新系统权限表

    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)

    测试新建用户

    [huser@master ~]$ mysql -u hive -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 10
    Server version: 5.1.73 Source distribution
    
    Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a 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> 

     为用户授权

    mysql> GRANT ALL PRIVILEGES ON *.* TO hive@localhost IDENTIFIED BY 'hive'; 
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)

     创建数据库

    mysql> create database hive;
    Query OK, 1 row affected (0.01 sec)
  • 相关阅读:
    1.2 文本域(含可编辑表格实现)
    JS手册目录
    1.1 文本框
    JS传中文到后台需要的处理
    java基础和面向对象面试题_01
    try {}里有一个return语句,那么紧跟在这个try后的finally {}里的code会不会被执行,什么时候被执行,在return前还是后?
    java面试题:当一个对象被当作参数传递到一个方法后,此方法可改变这个对象的属性,并可返回变化后的结果,那么这里到底是值传递还是引用传递?
    java基础学习_IO流04_用户登录注册案例(IO版)、数据操作流(操作基本数据类型的流)、内存操作流、打印流、标准输入输出流、随机访问流、合并流、序列化流(对象操作流)、Properties属性集合类、NIO(新IO)_day22总结
    思想:java中,父类的方法中传入的形参的数据类型是泛型,子类的方法的形参想只要一种确定的数据类型,子类该如何做呢?
    几种后端开发技术的选型调研
  • 原文地址:https://www.cnblogs.com/guarder/p/3707895.html
Copyright © 2011-2022 走看看