这两天在研究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
-
[root@localhost soft]# rpm -ivh MySQL-server-5.6.26-1.linux_glibc2.5.i386.rpm --force --nodeps
-
warning: MySQL-server-5.6.26-1.linux_glibc2.5.i386.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
-
Preparing... ################################# [100%]
-
Updating / installing...
-
1:MySQL-server-5.6.26-1.linux_glibc################################# [100%]
-
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).
-
2015-08-07 23:04:54 0 [Note] /usr/sbin/mysqld (mysqld 5.6.26) starting as process 16096 ...
-
2015-08-07 23:04:54 16096 [Note] InnoDB: Using mutexes to ref count buffer pool pages
-
2015-08-07 23:04:54 16096 [Note] InnoDB: The InnoDB memory heap is disabled
-
2015-08-07 23:04:54 16096 [Note] InnoDB: Mutexes and rw_locks use InnoDB's own implementation
-
2015-08-07 23:04:54 16096 [Note] InnoDB: Memory barrier is not used
-
2015-08-07 23:04:54 16096 [Note] InnoDB: Compressed tables use zlib 1.2.3
-
2015-08-07 23:04:54 16096 [Note] InnoDB: Using Linux native AIO
-
2015-08-07 23:04:54 16096 [Note] InnoDB: Not using CPU crc32 instructions
-
2015-08-07 23:04:54 16096 [Note] InnoDB: Initializing buffer pool, size = 128.0M
-
2015-08-07 23:04:54 16096 [Note] InnoDB: Completed initialization of buffer pool
-
2015-08-07 23:04:54 16096 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
-
2015-08-07 23:04:54 16096 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
-
2015-08-07 23:04:54 16096 [Note] InnoDB: Database physically writes the file full: wait...
-
2015-08-07 23:04:55 16096 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
-
2015-08-07 23:04:57 16096 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
-
2015-08-07 23:04:59 16096 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
-
2015-08-07 23:04:59 16096 [Warning] InnoDB: New log files created, LSN=45781
-
2015-08-07 23:04:59 16096 [Note] InnoDB: Doublewrite buffer not found: creating new
-
2015-08-07 23:04:59 16096 [Note] InnoDB: Doublewrite buffer created
-
2015-08-07 23:04:59 16096 [Note] InnoDB: 128 rollback segment(s) are active.
-
2015-08-07 23:04:59 16096 [Warning] InnoDB: Creating foreign key constraint system tables.
-
2015-08-07 23:04:59 16096 [Note] InnoDB: Foreign key constraint system tables created
-
2015-08-07 23:04:59 16096 [Note] InnoDB: Creating tablespace and datafile system tables.
-
2015-08-07 23:04:59 16096 [Note] InnoDB: Tablespace and datafile system tables created.
-
2015-08-07 23:04:59 16096 [Note] InnoDB: Waiting for purge to start
-
2015-08-07 23:04:59 16096 [Note] InnoDB: 5.6.26 started; log sequence number 0
-
A random root password has been set. You will find it in '/root/.mysql_secret'.
-
2015-08-07 23:05:03 16096 [Note] Binlog end
-
2015-08-07 23:05:03 16096 [Note] InnoDB: FTS optimize thread exiting.
-
2015-08-07 23:05:03 16096 [Note] InnoDB: Starting shutdown...
-
2015-08-07 23:05:05 16096 [Note] InnoDB: Shutdown completed; log sequence number 1625977
-
-
-
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).
-
2015-08-07 23:05:05 0 [Note] /usr/sbin/mysqld (mysqld 5.6.26) starting as process 16118 ...
-
2015-08-07 23:05:05 16118 [Note] InnoDB: Using mutexes to ref count buffer pool pages
-
2015-08-07 23:05:05 16118 [Note] InnoDB: The InnoDB memory heap is disabled
-
2015-08-07 23:05:05 16118 [Note] InnoDB: Mutexes and rw_locks use InnoDB's own implementation
-
2015-08-07 23:05:05 16118 [Note] InnoDB: Memory barrier is not used
-
2015-08-07 23:05:05 16118 [Note] InnoDB: Compressed tables use zlib 1.2.3
-
2015-08-07 23:05:05 16118 [Note] InnoDB: Using Linux native AIO
-
2015-08-07 23:05:05 16118 [Note] InnoDB: Not using CPU crc32 instructions
-
2015-08-07 23:05:05 16118 [Note] InnoDB: Initializing buffer pool, size = 128.0M
-
2015-08-07 23:05:05 16118 [Note] InnoDB: Completed initialization of buffer pool
-
2015-08-07 23:05:05 16118 [Note] InnoDB: Highest supported file format is Barracuda.
-
2015-08-07 23:05:05 16118 [Note] InnoDB: 128 rollback segment(s) are active.
-
2015-08-07 23:05:05 16118 [Note] InnoDB: Waiting for purge to start
-
2015-08-07 23:05:06 16118 [Note] InnoDB: 5.6.26 started; log sequence number 1625977
-
2015-08-07 23:05:06 16118 [Note] Binlog end
-
2015-08-07 23:05:06 16118 [Note] InnoDB: FTS optimize thread exiting.
-
2015-08-07 23:05:06 16118 [Note] InnoDB: Starting shutdown...
-
2015-08-07 23:05:07 16118 [Note] InnoDB: Shutdown completed; log sequence number 1625987
-
-
-
-
-
A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
-
You will find that password in '/root/.mysql_secret'.
-
-
You must change that password on your first connect,
-
no other statement but 'SET PASSWORD' will be accepted.
-
See the manual for the semantics of the 'password expired' flag.
-
-
Also, the account for the anonymous user has been removed.
-
-
In addition, you can run:
-
-
/usr/bin/mysql_secure_installation
-
-
which will also give you the option of removing the test database.
-
This is strongly recommended for production servers.
-
-
See the manual for more instructions.
-
-
Please report any problems at
-
-
The latest information about MySQL is available on the web at
-
-
-
-
Support MySQL by buying support/licenses at
-
-
New default config file was created as /usr/my.cnf and
-
will be used by default by the server when you start it.
-
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
登陆修改密码
-
[root@localhost soft]# mysql -p mysql
-
Enter password:
-
Welcome to the MySQL monitor. Commands end with ; or \g.
-
Your MySQL connection id is 2
-
Server version: 5.6.26
-
-
Copyright (c) 2000, 2015, 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> show databases;
-
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
-
mysql> SET PASSWORD=PASSWORD('fx1234');
-
Query OK, 0 rows affected (0.00 sec)
-
-
mysql> flush privileges;
-
Query OK, 0 rows affected (0.00 sec)
-
-
mysql> \q;
-
Bye
-
[root@localhost soft]# mysql -uroot -p
-
Enter password:
-
Welcome to the MySQL monitor. Commands end with ; or \g.
-
Your MySQL connection id is 3
-
Server version: 5.6.26 MySQL Community Server (GPL)
-
-
Copyright (c) 2000, 2015, 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>
至此安装成功
mysql5.7 需要libnuma.so.1, yum -y install libnuma*
http://dev.mysql.com/doc/refman/5.7/en/linux-installation-rpm.html
密码: 官方说法是初次安装后 会写入mysqld.log
-
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';
yum -y install libnuma*