Chinaunix首页 | 论坛 | 博客
  • 博客访问: 278918
  • 博文数量: 73
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 452
  • 用 户 组: 普通用户
  • 注册时间: 2014-09-22 17:07
个人简介

心态决定命运

文章分类

全部博文(73)

文章存档

2017年(21)

2016年(27)

2015年(21)

2014年(4)

我的朋友

分类: Mysql/postgreSQL

2015-08-07 23:21:50

    这两天在研究CACTI,安装时需要用到Mysql,特将mysql安装过程记录下来以作参考。

1. 从官方网站下载mysql

    [root@localhost soft]# uname -a
    Linux localhost.localdomain 3.19.8-100.fc20.i686+PAE #1 SMP Tue May 12 17:27:49 UTC 2015 i686 i686 i386 GNU/Linux
    下载后文件:
    -rw-r--r--.  1 root root  310927360 Aug  6 18:17 MySQL-5.6.26-1.linux_glibc2.5.i386.rpm-bundle.tar
    解压后:
    -rw-r--r--.  1 7155 wheel  22938679 Jul 16 01:16 MySQL-client-5.6.26-1.linux_glibc2.5.i386.rpm  #MySQL客户端程序
    -rw-r--r--.  1 7155 wheel   4193155 Jul 16 01:16 MySQL-devel-5.6.26-1.linux_glibc2.5.i386.rpm  #MySQL的库和头文件
    -rw-r--r--.  1 7155 wheel 112996058 Jul 16 01:16 MySQL-embedded-5.6.26-1.linux_glibc2.5.i386.rpm #MySQL的嵌入式程序
    -rw-r--r--.  1 7155 wheel  88246330 Jul 16 01:17 MySQL-server-5.6.26-1.linux_glibc2.5.i386.rpm  #MySQL服务端程序
    -rw-r--r--.  1 7155 wheel   2372591 Jul 16 01:18 MySQL-shared-5.6.26-1.linux_glibc2.5.i386.rpm  #MySQL的共享库
    -rw-r--r--.  1 7155 wheel   5368258 Jul 16 01:18 MySQL-shared-compat-5.6.26-1.linux_glibc2.5.i386.rpm #RHEL兼容包
    -rw-r--r--.  1 7155 wheel  74801357 Jul 16 01:18 MySQL-test-5.6.26-1.linux_glibc2.5.i386.rpm  #MySQL的测试组件
 

2. 安装server 和client

    .删除之前安装的mysql

    [root@localhost soft]# rpm -qa |grep -i mysql |xargs rpm -ev
    Preparing packages...
    MySQL-server-5.6.26-1.linux_glibc2.5.i386
    MySQL-client-5.6.26-1.linux_glibc2.5.i386
   

    .安装server

    添加用户mysql
    oot@localhost soft]# groupadd mysql
    [root@localhost soft]# useradd -r -g mysql mysql
    [root@localhost soft]# id mysql
    uid=989(mysql) gid=1001(mysql) groups=1001(mysql)


     首次安装失败
    rpm -ivh MySQL-server-5.6.26-1.linux_glibc2.5.i386.rpm
    warning: MySQL-server-5.6.26-1.linux_glibc2.5.i386.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
    Preparing...                          ################################# [100%]
        file /usr/share/mysql/charsets/README from install of MySQL-server-5.6.26-1.linux_glibc2.5.i386 conflicts with file from package      mariadb-libs-1:5.5.43-1.fc20.i686
        file /usr/share/mysql/czech/errmsg.sys from install of MySQL-server-5.6.26-1.linux_glibc2.5.i386 conflicts with file from package     mariadb-libs-1:5.5.43-1.fc20.i686
    添加--force --nodeps
    [root@localhost soft]# rpm -ivh MySQL-server-5.6.26-1.linux_glibc2.5.i386.rpm --force --nodeps
   

点击(此处)折叠或打开

  1. [root@localhost soft]# rpm -ivh MySQL-server-5.6.26-1.linux_glibc2.5.i386.rpm --force --nodeps
  2. warning: MySQL-server-5.6.26-1.linux_glibc2.5.i386.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
  3. Preparing... ################################# [100%]
  4. Updating / installing...
  5. 1:MySQL-server-5.6.26-1.linux_glibc################################# [100%]
  6. 2015-08-07 23:04:54 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  7. 2015-08-07 23:04:54 0 [Note] /usr/sbin/mysqld (mysqld 5.6.26) starting as process 16096 ...
  8. 2015-08-07 23:04:54 16096 [Note] InnoDB: Using mutexes to ref count buffer pool pages
  9. 2015-08-07 23:04:54 16096 [Note] InnoDB: The InnoDB memory heap is disabled
  10. 2015-08-07 23:04:54 16096 [Note] InnoDB: Mutexes and rw_locks use InnoDB's own implementation
  11. 2015-08-07 23:04:54 16096 [Note] InnoDB: Memory barrier is not used
  12. 2015-08-07 23:04:54 16096 [Note] InnoDB: Compressed tables use zlib 1.2.3
  13. 2015-08-07 23:04:54 16096 [Note] InnoDB: Using Linux native AIO
  14. 2015-08-07 23:04:54 16096 [Note] InnoDB: Not using CPU crc32 instructions
  15. 2015-08-07 23:04:54 16096 [Note] InnoDB: Initializing buffer pool, size = 128.0M
  16. 2015-08-07 23:04:54 16096 [Note] InnoDB: Completed initialization of buffer pool
  17. 2015-08-07 23:04:54 16096 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
  18. 2015-08-07 23:04:54 16096 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
  19. 2015-08-07 23:04:54 16096 [Note] InnoDB: Database physically writes the file full: wait...
  20. 2015-08-07 23:04:55 16096 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
  21. 2015-08-07 23:04:57 16096 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
  22. 2015-08-07 23:04:59 16096 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
  23. 2015-08-07 23:04:59 16096 [Warning] InnoDB: New log files created, LSN=45781
  24. 2015-08-07 23:04:59 16096 [Note] InnoDB: Doublewrite buffer not found: creating new
  25. 2015-08-07 23:04:59 16096 [Note] InnoDB: Doublewrite buffer created
  26. 2015-08-07 23:04:59 16096 [Note] InnoDB: 128 rollback segment(s) are active.
  27. 2015-08-07 23:04:59 16096 [Warning] InnoDB: Creating foreign key constraint system tables.
  28. 2015-08-07 23:04:59 16096 [Note] InnoDB: Foreign key constraint system tables created
  29. 2015-08-07 23:04:59 16096 [Note] InnoDB: Creating tablespace and datafile system tables.
  30. 2015-08-07 23:04:59 16096 [Note] InnoDB: Tablespace and datafile system tables created.
  31. 2015-08-07 23:04:59 16096 [Note] InnoDB: Waiting for purge to start
  32. 2015-08-07 23:04:59 16096 [Note] InnoDB: 5.6.26 started; log sequence number 0
  33. A random root password has been set. You will find it in '/root/.mysql_secret'.
  34. 2015-08-07 23:05:03 16096 [Note] Binlog end
  35. 2015-08-07 23:05:03 16096 [Note] InnoDB: FTS optimize thread exiting.
  36. 2015-08-07 23:05:03 16096 [Note] InnoDB: Starting shutdown...
  37. 2015-08-07 23:05:05 16096 [Note] InnoDB: Shutdown completed; log sequence number 1625977


  38. 2015-08-07 23:05:05 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  39. 2015-08-07 23:05:05 0 [Note] /usr/sbin/mysqld (mysqld 5.6.26) starting as process 16118 ...
  40. 2015-08-07 23:05:05 16118 [Note] InnoDB: Using mutexes to ref count buffer pool pages
  41. 2015-08-07 23:05:05 16118 [Note] InnoDB: The InnoDB memory heap is disabled
  42. 2015-08-07 23:05:05 16118 [Note] InnoDB: Mutexes and rw_locks use InnoDB's own implementation
  43. 2015-08-07 23:05:05 16118 [Note] InnoDB: Memory barrier is not used
  44. 2015-08-07 23:05:05 16118 [Note] InnoDB: Compressed tables use zlib 1.2.3
  45. 2015-08-07 23:05:05 16118 [Note] InnoDB: Using Linux native AIO
  46. 2015-08-07 23:05:05 16118 [Note] InnoDB: Not using CPU crc32 instructions
  47. 2015-08-07 23:05:05 16118 [Note] InnoDB: Initializing buffer pool, size = 128.0M
  48. 2015-08-07 23:05:05 16118 [Note] InnoDB: Completed initialization of buffer pool
  49. 2015-08-07 23:05:05 16118 [Note] InnoDB: Highest supported file format is Barracuda.
  50. 2015-08-07 23:05:05 16118 [Note] InnoDB: 128 rollback segment(s) are active.
  51. 2015-08-07 23:05:05 16118 [Note] InnoDB: Waiting for purge to start
  52. 2015-08-07 23:05:06 16118 [Note] InnoDB: 5.6.26 started; log sequence number 1625977
  53. 2015-08-07 23:05:06 16118 [Note] Binlog end
  54. 2015-08-07 23:05:06 16118 [Note] InnoDB: FTS optimize thread exiting.
  55. 2015-08-07 23:05:06 16118 [Note] InnoDB: Starting shutdown...
  56. 2015-08-07 23:05:07 16118 [Note] InnoDB: Shutdown completed; log sequence number 1625987




  57. A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
  58. You will find that password in '/root/.mysql_secret'.

  59. You must change that password on your first connect,
  60. no other statement but 'SET PASSWORD' will be accepted.
  61. See the manual for the semantics of the 'password expired' flag.

  62. Also, the account for the anonymous user has been removed.

  63. In addition, you can run:

  64. /usr/bin/mysql_secure_installation

  65. which will also give you the option of removing the test database.
  66. This is strongly recommended for production servers.

  67. See the manual for more instructions.

  68. Please report any problems at

  69. The latest information about MySQL is available on the web at


  70. Support MySQL by buying support/licenses at

  71. New default config file was created as /usr/my.cnf and
  72. will be used by default by the server when you start it.
  73. You may edit this file to change server settings

    .安装client

    [root@localhost soft]# rpm -ivh MySQL-client-5.6.26-1.linux_glibc2.5.i386.rpm
    warning: MySQL-client-5.6.26-1.linux_glibc2.5.i386.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
    Preparing...                          ################################# [100%]
    Updating / installing...
       1:MySQL-client-5.6.26-1.linux_glibc################################# [100%]

    .cp配置文件

    [root@localhost soft]# cp /usr/share/mysql/my-default.cnf /etc/my.cnf
   

   . 启动mysql

   查看状态
     [root@localhost soft]# service mysql status
     ERROR! MySQL is not running
    [root@localhost soft]# systemctl status mysql.service
    mysql.service - LSB: start and stop MySQL
       Loaded: loaded (/etc/rc.d/init.d/mysql)
       Active: active (exited) since Fri 2015-08-07 16:21:19 HKT; 6h ago

    Aug 07 16:21:16 localhost.localdomain systemd[1]: Starting LSB: start and stop MySQL...
    Aug 07 16:21:19 localhost.localdomain mysql[1141]: Starting MySQL... SUCCESS!
    Aug 07 16:21:19 localhost.localdomain systemd[1]: Started LSB: start and stop MySQL.
    Aug 07 18:13:15 localhost.localdomain systemd[1]: Started LSB: start and stop MySQL.
    Aug 07 18:13:22 localhost.localdomain systemd[1]: Started LSB: start and stop MySQL.
    Aug 07 21:41:20 localhost.localdomain systemd[1]: Started LSB: start and stop MySQL.
    Aug 07 21:41:35 localhost.localdomain systemd[1]: Started LSB: start and stop MySQL.
    启动
    [root@localhost soft]# service mysql start
    Starting MySQL.. SUCCESS!
    [root@localhost soft]# netstat -lpnt |grep 3306
    tcp6       0      0 :::3306                 :::*                    LISTEN      15768/mysqld        
    
   查看密码
   [root@localhost soft]# nl /root/.mysql_secret
     1    # The random password set for the root user at Fri Aug  7 21:19:42 2015 (local time): hIZYPKoqKiNZqJRO
    登陆修改密码
   

点击(此处)折叠或打开

  1. [root@localhost soft]# mysql -p mysql
  2. Enter password:
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 2
  5. Server version: 5.6.26

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

  7. Oracle is a registered trademark of Oracle Corporation and/or its
  8. affiliates. Other names may be trademarks of their respective
  9. owners.

  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  11. mysql> show databases;
  12. ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
  13. mysql> SET PASSWORD=PASSWORD('fx1234');
  14. Query OK, 0 rows affected (0.00 sec)

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

  17. mysql> \q;
  18. Bye
  19. [root@localhost soft]# mysql -uroot -p
  20. Enter password:
  21. Welcome to the MySQL monitor. Commands end with ; or \g.
  22. Your MySQL connection id is 3
  23. Server version: 5.6.26 MySQL Community Server (GPL)

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

  25. Oracle is a registered trademark of Oracle Corporation and/or its
  26. affiliates. Other names may be trademarks of their respective
  27. owners.

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

  29. mysql>
    至此安装成功

  mysql5.7 需要libnuma.so.1, yum -y install libnuma*
        http://dev.mysql.com/doc/refman/5.7/en/linux-installation-rpm.html
        密码: 官方说法是初次安装后 会写入mysqld.log  
       

点击(此处)折叠或打开

  1. shell> grep 'temporary password' /var/log/mysqld.log
       我这里测试没找到密码,只发现下面日志
      Access denied for user 'UNKNOWN_MYSQL_USER'@'localhost' (using password: NO))
       解决方法:在my.cnf 中添加skip-grant-tables
        service mysqld restart
       mysql -u mysql
        update user  set authentication_string=password('123456') where user='root' and host='localhost';
        flush privileges;
        service mysqld stop
         my.cnf 中 屏蔽skip-grant-tables
        service mysqld start
        mysql -uroot -p123456
        alter user 'root'@'localhost' identified by '123456';

     
        
        






   

  
   

阅读(956) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~