[测试环境]
CentOS 5.7 x64
[安装MySQL]
1. 下载Mysql
Red Hat & Oracle Linux 5 (x86, 64-bit), RPM Package
MySQL Server 5.6.11 84.2M
Download
(MySQL-server-5.6.11-2.rhel5.x86_64.rpm) MD5: 944e3e425becf3ef7ad5f191e0e1f04f
2. 安装Mysql
rpm -ivh MySQL-server-5.6.11-2.rhel5.x86_64.rpm
2013-05-14 14:04:13 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2013-05-14 14:04:13 5998 [Note] InnoDB: The InnoDB memory heap is disabled
2013-05-14 14:04:13 5998 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2013-05-14 14:04:13 5998 [Note] InnoDB: Compressed tables use zlib 1.2.3
2013-05-14 14:04:13 5998 [Note] InnoDB: Using Linux native AIO
2013-05-14 14:04:13 5998 [Note] InnoDB: Not using CPU crc32 instructions
2013-05-14 14:04:13 5998 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2013-05-14 14:04:13 5998 [Note] InnoDB: Completed initialization of buffer pool
2013-05-14 14:04:13 5998 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2013-05-14 14:04:13 5998 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2013-05-14 14:04:13 5998 [Note] InnoDB: Database physically writes the file full: wait...
2013-05-14 14:04:13 5998 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2013-05-14 14:04:14 5998 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2013-05-14 14:04:15 5998 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2013-05-14 14:04:15 5998 [Warning] InnoDB: New log files created, LSN=45781
2013-05-14 14:04:15 5998 [Note] InnoDB: Doublewrite buffer not found: creating new
2013-05-14 14:04:15 5998 [Note] InnoDB: Doublewrite buffer created
2013-05-14 14:04:15 5998 [Note] InnoDB: 128 rollback segment(s) are active.
2013-05-14 14:04:15 5998 [Warning] InnoDB: Creating foreign key constraint system tables.
2013-05-14 14:04:15 5998 [Note] InnoDB: Foreign key constraint system tables created
2013-05-14 14:04:15 5998 [Note] InnoDB: Creating tablespace and datafile system tables.
2013-05-14 14:04:15 5998 [Note] InnoDB: Tablespace and datafile system tables created.
2013-05-14 14:04:15 5998 [Note] InnoDB: Waiting for purge to start
2013-05-14 14:04:15 5998 [Note] InnoDB: 5.6.11 started; log sequence number 0
A random root password has been set. You will find it in '/root/.mysql_secret'.
2013-05-14 14:04:17 5998 [Note] Binlog end
2013-05-14 14:04:17 5998 [Note] InnoDB: FTS optimize thread exiting.
2013-05-14 14:04:17 5998 [Note] InnoDB: Starting shutdown...
2013-05-14 14:04:18 5998 [Note] InnoDB: Shutdown completed; log sequence number 1625977
2013-05-14 14:04:18 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2013-05-14 14:04:18 6022 [Note] InnoDB: The InnoDB memory heap is disabled
2013-05-14 14:04:18 6022 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2013-05-14 14:04:18 6022 [Note] InnoDB: Compressed tables use zlib 1.2.3
2013-05-14 14:04:18 6022 [Note] InnoDB: Using Linux native AIO
2013-05-14 14:04:18 6022 [Note] InnoDB: Not using CPU crc32 instructions
2013-05-14 14:04:18 6022 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2013-05-14 14:04:18 6022 [Note] InnoDB: Completed initialization of buffer pool
2013-05-14 14:04:18 6022 [Note] InnoDB: Highest supported file format is Barracuda.
2013-05-14 14:04:18 6022 [Note] InnoDB: 128 rollback segment(s) are active.
2013-05-14 14:04:18 6022 [Note] InnoDB: Waiting for purge to start
2013-05-14 14:04:18 6022 [Note] InnoDB: 5.6.11 started; log sequence number 1625977
2013-05-14 14:04:18 6022 [Note] Binlog end
2013-05-14 14:04:18 6022 [Note] InnoDB: FTS optimize thread exiting.
2013-05-14 14:04:18 6022 [Note] InnoDB: Starting shutdown...
2013-05-14 14:04:20 6022 [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 with the /usr/bin/mysqlbug script!
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
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
查看安装的文件 :
[root@db-172-16-3-33 soft_bak]# rpm -qa|grep MySQL
MySQL-server-5.6.11-2.rhel5
[root@db-172-16-3-33 soft_bak]# rpm -ql MySQL-server-5.6.11-2.rhel5
/etc/init.d/mysql
/etc/logrotate.d/mysql
/etc/my.cnf
/usr/bin/innochecksum
/usr/bin/my_print_defaults
/usr/bin/myisam_ftdump
/usr/bin/myisamchk
/usr/bin/myisamlog
/usr/bin/myisampack
/usr/bin/mysql_convert_table_format
/usr/bin/mysql_fix_extensions
/usr/bin/mysql_install_db
/usr/bin/mysql_plugin
/usr/bin/mysql_secure_installation
/usr/bin/mysql_setpermission
/usr/bin/mysql_tzinfo_to_sql
/usr/bin/mysql_upgrade
/usr/bin/mysql_zap
/usr/bin/mysqlbug
/usr/bin/mysqld_multi
/usr/bin/mysqld_safe
/usr/bin/mysqldumpslow
/usr/bin/mysqlhotcopy
/usr/bin/mysqltest
/usr/bin/perror
/usr/bin/replace
/usr/bin/resolve_stack_dump
/usr/bin/resolveip
/usr/lib64/mysql/libtcmalloc_minimal.so
/usr/lib64/mysql/plugin/adt_null.so
/usr/lib64/mysql/plugin/auth.so
/usr/lib64/mysql/plugin/auth_socket.so
/usr/lib64/mysql/plugin/auth_test_plugin.so
/usr/lib64/mysql/plugin/daemon_example.ini
/usr/lib64/mysql/plugin/debug/adt_null.so
/usr/lib64/mysql/plugin/debug/auth.so
/usr/lib64/mysql/plugin/debug/auth_socket.so
/usr/lib64/mysql/plugin/debug/auth_test_plugin.so
/usr/lib64/mysql/plugin/debug/libdaemon_example.so
/usr/lib64/mysql/plugin/debug/mypluglib.so
/usr/lib64/mysql/plugin/debug/qa_auth_client.so
/usr/lib64/mysql/plugin/debug/qa_auth_interface.so
/usr/lib64/mysql/plugin/debug/qa_auth_server.so
/usr/lib64/mysql/plugin/debug/semisync_master.so
/usr/lib64/mysql/plugin/debug/semisync_slave.so
/usr/lib64/mysql/plugin/debug/validate_password.so
/usr/lib64/mysql/plugin/libdaemon_example.so
/usr/lib64/mysql/plugin/mypluglib.so
/usr/lib64/mysql/plugin/qa_auth_client.so
/usr/lib64/mysql/plugin/qa_auth_interface.so
/usr/lib64/mysql/plugin/qa_auth_server.so
/usr/lib64/mysql/plugin/semisync_master.so
/usr/lib64/mysql/plugin/semisync_slave.so
/usr/lib64/mysql/plugin/validate_password.so
/usr/sbin/mysqld
/usr/sbin/mysqld-debug
/usr/sbin/rcmysql
/usr/share/doc/MySQL-server-5.6.11
/usr/share/doc/MySQL-server-5.6.11/COPYING
/usr/share/doc/MySQL-server-5.6.11/ChangeLog
/usr/share/doc/MySQL-server-5.6.11/INFO_BIN
/usr/share/doc/MySQL-server-5.6.11/INFO_SRC
/usr/share/doc/MySQL-server-5.6.11/README
/usr/share/doc/MySQL-server-5.6.11/my-default.cnf
/usr/share/info/mysql.info.gz
/usr/share/man/man1/innochecksum.1.gz
/usr/share/man/man1/my_print_defaults.1.gz
/usr/share/man/man1/myisam_ftdump.1.gz
/usr/share/man/man1/myisamchk.1.gz
/usr/share/man/man1/myisamlog.1.gz
/usr/share/man/man1/myisampack.1.gz
/usr/share/man/man1/mysql.server.1.gz
/usr/share/man/man1/mysql_convert_table_format.1.gz
/usr/share/man/man1/mysql_fix_extensions.1.gz
/usr/share/man/man1/mysql_install_db.1.gz
/usr/share/man/man1/mysql_plugin.1.gz
/usr/share/man/man1/mysql_secure_installation.1.gz
/usr/share/man/man1/mysql_setpermission.1.gz
/usr/share/man/man1/mysql_tzinfo_to_sql.1.gz
/usr/share/man/man1/mysql_upgrade.1.gz
/usr/share/man/man1/mysql_zap.1.gz
/usr/share/man/man1/mysqlbug.1.gz
/usr/share/man/man1/mysqld_multi.1.gz
/usr/share/man/man1/mysqld_safe.1.gz
/usr/share/man/man1/mysqldumpslow.1.gz
/usr/share/man/man1/mysqlhotcopy.1.gz
/usr/share/man/man1/mysqlman.1.gz
/usr/share/man/man1/mysqltest.1.gz
/usr/share/man/man1/perror.1.gz
/usr/share/man/man1/replace.1.gz
/usr/share/man/man1/resolve_stack_dump.1.gz
/usr/share/man/man1/resolveip.1.gz
/usr/share/man/man8/mysqld.8.gz
/usr/share/mysql
/usr/share/mysql/SELinux
/usr/share/mysql/SELinux/RHEL4
/usr/share/mysql/SELinux/RHEL4/mysql.fc
/usr/share/mysql/SELinux/RHEL4/mysql.te
/usr/share/mysql/binary-configure
/usr/share/mysql/bulgarian
/usr/share/mysql/bulgarian/errmsg.sys
/usr/share/mysql/charsets
/usr/share/mysql/charsets/Index.xml
/usr/share/mysql/charsets/README
/usr/share/mysql/charsets/armscii8.xml
/usr/share/mysql/charsets/ascii.xml
/usr/share/mysql/charsets/cp1250.xml
/usr/share/mysql/charsets/cp1251.xml
/usr/share/mysql/charsets/cp1256.xml
/usr/share/mysql/charsets/cp1257.xml
/usr/share/mysql/charsets/cp850.xml
/usr/share/mysql/charsets/cp852.xml
/usr/share/mysql/charsets/cp866.xml
/usr/share/mysql/charsets/dec8.xml
/usr/share/mysql/charsets/geostd8.xml
/usr/share/mysql/charsets/greek.xml
/usr/share/mysql/charsets/hebrew.xml
/usr/share/mysql/charsets/hp8.xml
/usr/share/mysql/charsets/keybcs2.xml
/usr/share/mysql/charsets/koi8r.xml
/usr/share/mysql/charsets/koi8u.xml
/usr/share/mysql/charsets/latin1.xml
/usr/share/mysql/charsets/latin2.xml
/usr/share/mysql/charsets/latin5.xml
/usr/share/mysql/charsets/latin7.xml
/usr/share/mysql/charsets/macce.xml
/usr/share/mysql/charsets/macroman.xml
/usr/share/mysql/charsets/swe7.xml
/usr/share/mysql/czech
/usr/share/mysql/czech/errmsg.sys
/usr/share/mysql/danish
/usr/share/mysql/danish/errmsg.sys
/usr/share/mysql/dictionary.txt
/usr/share/mysql/dutch
/usr/share/mysql/dutch/errmsg.sys
/usr/share/mysql/english
/usr/share/mysql/english/errmsg.sys
/usr/share/mysql/errmsg-utf8.txt
/usr/share/mysql/estonian
/usr/share/mysql/estonian/errmsg.sys
/usr/share/mysql/fill_help_tables.sql
/usr/share/mysql/french
/usr/share/mysql/french/errmsg.sys
/usr/share/mysql/german
/usr/share/mysql/german/errmsg.sys
/usr/share/mysql/greek
/usr/share/mysql/greek/errmsg.sys
/usr/share/mysql/hungarian
/usr/share/mysql/hungarian/errmsg.sys
/usr/share/mysql/innodb_memcached_config.sql
/usr/share/mysql/italian
/usr/share/mysql/italian/errmsg.sys
/usr/share/mysql/japanese
/usr/share/mysql/japanese/errmsg.sys
/usr/share/mysql/korean
/usr/share/mysql/korean/errmsg.sys
/usr/share/mysql/magic
/usr/share/mysql/my-default.cnf
/usr/share/mysql/mysql-log-rotate
/usr/share/mysql/mysql.server
/usr/share/mysql/mysql_security_commands.sql
/usr/share/mysql/mysql_system_tables.sql
/usr/share/mysql/mysql_system_tables_data.sql
/usr/share/mysql/mysql_test_data_timezone.sql
/usr/share/mysql/mysqld_multi.server
/usr/share/mysql/norwegian
/usr/share/mysql/norwegian-ny
/usr/share/mysql/norwegian-ny/errmsg.sys
/usr/share/mysql/norwegian/errmsg.sys
/usr/share/mysql/polish
/usr/share/mysql/polish/errmsg.sys
/usr/share/mysql/portuguese
/usr/share/mysql/portuguese/errmsg.sys
/usr/share/mysql/romanian
/usr/share/mysql/romanian/errmsg.sys
/usr/share/mysql/russian
/usr/share/mysql/russian/errmsg.sys
/usr/share/mysql/serbian
/usr/share/mysql/serbian/errmsg.sys
/usr/share/mysql/slovak
/usr/share/mysql/slovak/errmsg.sys
/usr/share/mysql/solaris
/usr/share/mysql/solaris/postinstall-solaris
/usr/share/mysql/spanish
/usr/share/mysql/spanish/errmsg.sys
/usr/share/mysql/swedish
/usr/share/mysql/swedish/errmsg.sys
/usr/share/mysql/ukrainian
/usr/share/mysql/ukrainian/errmsg.sys
查看自启动配置
[root@db-172-16-3-33 soft_bak]# chkconfig --list|grep -i mysql
mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
查看新建的mysql用户.
cat /etc/passwd
mysql:x:101:157:MySQL server:/var/lib/mysql:/bin/bash
3. 启动Mysql
[root@db-172-16-3-33 mysql]# service mysql status
MySQL is not running[FAILED]
[root@db-172-16-3-33 mysql]# service mysql start
Starting MySQL.[ OK ]
[root@db-172-16-3-33 ~]# netstat -anp|grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 6254/mysqld
查看mysql数据文件位置 :
[root@db-172-16-3-33 ~]# lsof|grep mysql
mysqld_sa 6149 root cwd DIR 104,1 4096 1471681 /usr
mysqld_sa 6149 root rtd DIR 104,1 4096 2 /
mysqld_sa 6149 root txt REG 104,1 801528 6867877 /bin/bash
mysqld_sa 6149 root mem REG 104,1 143600 3270737 /lib64/ld-2.5.so
mysqld_sa 6149 root mem REG 104,1 1722304 3270738 /lib64/libc-2.5.so
mysqld_sa 6149 root mem REG 104,1 23360 3270742 /lib64/libdl-2.5.so
mysqld_sa 6149 root mem REG 104,1 15584 3270586 /lib64/libtermcap.so.2.0.8
mysqld_sa 6149 root mem REG 104,1 56426208 1478202 /usr/lib/locale/locale-archive
mysqld_sa 6149 root mem REG 104,1 25464 1570051 /usr/lib64/gconv/gconv-modules.cache
mysqld_sa 6149 root mem REG 104,1 53880 3270427 /lib64/libnss_files-2.5.so
mysqld_sa 6149 root 0r CHR 1,3 1887 /dev/null
mysqld_sa 6149 root 1w CHR 1,3 1887 /dev/null
mysqld_sa 6149 root 2w CHR 1,3 1887 /dev/null
mysqld_sa 6149 root 255r REG 104,1 24687 1503074 /usr/bin/mysqld_safe
mysqld 6254 mysql cwd DIR 104,1 4096 6279393 /var/lib/mysql
mysqld 6254 mysql rtd DIR 104,1 4096 2 /
mysqld 6254 mysql txt REG 104,1 75802320 1503082 /usr/sbin/mysqld
mysqld 6254 mysql mem REG 104,1 143600 3270737 /lib64/ld-2.5.so
mysqld 6254 mysql mem REG 104,1 1722304 3270738 /lib64/libc-2.5.so
mysqld 6254 mysql mem REG 104,1 23360 3270742 /lib64/libdl-2.5.so
mysqld 6254 mysql mem REG 104,1 145824 3270747 /lib64/libpthread-2.5.so
mysqld 6254 mysql mem REG 104,1 615136 3270740 /lib64/libm-2.5.so
mysqld 6254 mysql mem REG 104,1 53448 3270748 /lib64/librt-2.5.so
mysqld 6254 mysql mem REG 104,1 58400 3270741 /lib64/libgcc_s-4.1.2-20080825.so.1
mysqld 6254 mysql mem REG 104,1 48600 3270739 /lib64/libcrypt-2.5.so
mysqld 6254 mysql mem REG 104,1 976312 1497692 /usr/lib64/libstdc++.so.6.0.8
mysqld 6254 mysql mem REG 104,1 53880 3270427 /lib64/libnss_files-2.5.so
mysqld 6254 mysql mem REG 104,1 3768 1481544 /usr/lib64/libaio.so.1.0.1
mysqld 6254 mysql 0r CHR 1,3 1887 /dev/null
mysqld 6254 mysql 1w REG 104,1 1888 6279621 /var/lib/mysql/db-172-16-3-33.sky-mobi.com.err
mysqld 6254 mysql 2w REG 104,1 1888 6279621 /var/lib/mysql/db-172-16-3-33.sky-mobi.com.err
mysqld 6254 mysql 3uW REG 104,1 12582912 6279479 /var/lib/mysql/ibdata1
mysqld 6254 mysql 4u REG 104,1 0 4840199 /tmp/ibFa6Fk6 (deleted)
mysqld 6254 mysql 5u REG 104,1 0 4840204 /tmp/ibMccrK5 (deleted)
mysqld 6254 mysql 6u REG 104,1 0 4840205 /tmp/ibWqxca5 (deleted)
mysqld 6254 mysql 7u REG 104,1 0 4840206 /tmp/ibr7ME33 (deleted)
mysqld 6254 mysql 8uW REG 104,1 50331648 6279480 /var/lib/mysql/ib_logfile0
mysqld 6254 mysql 9uW REG 104,1 50331648 6279481 /var/lib/mysql/ib_logfile1
mysqld 6254 mysql 10u IPv4 187925 TCP *:mysql (LISTEN)
mysqld 6254 mysql 11u REG 104,1 0 4840207 /tmp/ibKWpCB3 (deleted)
mysqld 6254 mysql 12u unix 0xffff8103a8a1b180 187926 /var/lib/mysql/mysql.sock
mysqld 6254 mysql 13u REG 104,1 2048 6279486 /var/lib/mysql/mysql/user.MYI
mysqld 6254 mysql 14u REG 104,1 568 6279487 /var/lib/mysql/mysql/user.MYD
mysqld 6254 mysql 15u REG 104,1 5120 6279483 /var/lib/mysql/mysql/db.MYI
mysqld 6254 mysql 16u REG 104,1 880 6279484 /var/lib/mysql/mysql/db.MYD
mysqld 6254 mysql 17u REG 104,1 5120 6279618 /var/lib/mysql/mysql/proxies_priv.MYI
mysqld 6254 mysql 18u REG 104,1 1386 6279619 /var/lib/mysql/mysql/proxies_priv.MYD
mysqld 6254 mysql 19u REG 104,1 4096 6279498 /var/lib/mysql/mysql/tables_priv.MYI
mysqld 6254 mysql 20u REG 104,1 0 6279499 /var/lib/mysql/mysql/tables_priv.MYD
mysqld 6254 mysql 21u REG 104,1 4096 6279501 /var/lib/mysql/mysql/columns_priv.MYI
mysqld 6254 mysql 22u REG 104,1 0 6279502 /var/lib/mysql/mysql/columns_priv.MYD
mysqld 6254 mysql 23u REG 104,1 4096 6279534 /var/lib/mysql/mysql/procs_priv.MYI
mysqld 6254 mysql 24u REG 104,1 0 6279535 /var/lib/mysql/mysql/procs_priv.MYD
mysqld 6254 mysql 25u REG 104,1 1024 6279495 /var/lib/mysql/mysql/servers.MYI
mysqld 6254 mysql 26u REG 104,1 0 6279496 /var/lib/mysql/mysql/servers.MYD
mysqld 6254 mysql 27u REG 104,1 2048 6279548 /var/lib/mysql/mysql/event.MYI
mysqld 6254 mysql 28u REG 104,1 0 6279549 /var/lib/mysql/mysql/event.MYD
4. 安装MySQL客户端
[root@db-172-16-3-33 soft_bak]# rpm -ivh MySQL-client-5.6.11-2.rhel5.x86_64.rpm
Preparing... ########################################### [100%]
1:MySQL-client ########################################### [100%]
[root@db-172-16-3-33 soft_bak]# rpm -ql MySQL-client-5.6.11-2.rhel5
/usr/bin/msql2mysql
/usr/bin/mysql
/usr/bin/mysql_config_editor
/usr/bin/mysql_find_rows
/usr/bin/mysql_waitpid
/usr/bin/mysqlaccess
/usr/bin/mysqlaccess.conf
/usr/bin/mysqladmin
/usr/bin/mysqlbinlog
/usr/bin/mysqlcheck
/usr/bin/mysqldump
/usr/bin/mysqlimport
/usr/bin/mysqlshow
/usr/bin/mysqlslap
/usr/share/man/man1/msql2mysql.1.gz
/usr/share/man/man1/mysql.1.gz
/usr/share/man/man1/mysql_config_editor.1.gz
/usr/share/man/man1/mysql_find_rows.1.gz
/usr/share/man/man1/mysql_waitpid.1.gz
/usr/share/man/man1/mysqlaccess.1.gz
/usr/share/man/man1/mysqladmin.1.gz
/usr/share/man/man1/mysqlbinlog.1.gz
/usr/share/man/man1/mysqlcheck.1.gz
/usr/share/man/man1/mysqldump.1.gz
/usr/share/man/man1/mysqlimport.1.gz
/usr/share/man/man1/mysqlshow.1.gz
/usr/share/man/man1/mysqlslap.1.gz
5. 连接Mysql
[root@db-172-16-3-33 soft_bak]# mysql -p
Enter password:
密码为安装数据库时生成的随机密码.
[root@db-172-16-3-33 soft_bak]# cat ~/.mysql_secret
# The random password set for the root user at Tue May 14 14:04:16 2013 (local time): Jk4ZPb1i
初始化密码 :
mysql> SET PASSWORD = PASSWORD('root');
Query OK, 0 rows affected (0.00 sec)
下次登录时密码为root.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| event |
| func |
| general_log |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| innodb_index_stats |
| innodb_table_stats |
| ndb_binlog_index |
| plugin |
| proc |
| procs_priv |
| proxies_priv |
| servers |
| slave_master_info |
| slave_relay_log_info |
| slave_worker_info |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+
28 rows in set (0.00 sec)
6. 安装Mysql 开发包. sysbench需要用到头文件和库文件.
注意需要5.6以下版本, 安装此版本将有问题, 具体见末尾部分.
[root@db-172-16-3-33 soft_bak]# rpm -ivh MySQL-devel-5.6.11-2.rhel5.x86_64.rpm
Preparing... ########################################### [100%]
1:MySQL-devel ########################################### [100%]
r[root@db-172-16-3-33 soft_bak]# rpm -ql MySQL-devel-5.6.11-2.rhel5
/usr/bin/mysql_config
/usr/include/mysql
/usr/include/mysql/big_endian.h
/usr/include/mysql/byte_order_generic.h
/usr/include/mysql/byte_order_generic_x86.h
/usr/include/mysql/byte_order_generic_x86_64.h
/usr/include/mysql/decimal.h
/usr/include/mysql/errmsg.h
/usr/include/mysql/keycache.h
/usr/include/mysql/little_endian.h
/usr/include/mysql/m_ctype.h
/usr/include/mysql/m_string.h
/usr/include/mysql/my_alloc.h
/usr/include/mysql/my_attribute.h
/usr/include/mysql/my_byteorder.h
/usr/include/mysql/my_compiler.h
/usr/include/mysql/my_config.h
/usr/include/mysql/my_dbug.h
/usr/include/mysql/my_dir.h
/usr/include/mysql/my_getopt.h
/usr/include/mysql/my_global.h
/usr/include/mysql/my_list.h
/usr/include/mysql/my_net.h
/usr/include/mysql/my_pthread.h
/usr/include/mysql/my_sys.h
/usr/include/mysql/my_xml.h
/usr/include/mysql/mysql
/usr/include/mysql/mysql.h
/usr/include/mysql/mysql/client_authentication.h
/usr/include/mysql/mysql/client_plugin.h
/usr/include/mysql/mysql/client_plugin.h.pp
/usr/include/mysql/mysql/get_password.h
/usr/include/mysql/mysql/innodb_priv.h
/usr/include/mysql/mysql/plugin.h
/usr/include/mysql/mysql/plugin_audit.h
/usr/include/mysql/mysql/plugin_audit.h.pp
/usr/include/mysql/mysql/plugin_auth.h
/usr/include/mysql/mysql/plugin_auth.h.pp
/usr/include/mysql/mysql/plugin_auth_common.h
/usr/include/mysql/mysql/plugin_ftparser.h
/usr/include/mysql/mysql/plugin_ftparser.h.pp
/usr/include/mysql/mysql/plugin_validate_password.h
/usr/include/mysql/mysql/psi
/usr/include/mysql/mysql/psi/mysql_file.h
/usr/include/mysql/mysql/psi/mysql_idle.h
/usr/include/mysql/mysql/psi/mysql_socket.h
/usr/include/mysql/mysql/psi/mysql_stage.h
/usr/include/mysql/mysql/psi/mysql_statement.h
/usr/include/mysql/mysql/psi/mysql_table.h
/usr/include/mysql/mysql/psi/mysql_thread.h
/usr/include/mysql/mysql/psi/psi.h
/usr/include/mysql/mysql/service_my_plugin_log.h
/usr/include/mysql/mysql/service_my_snprintf.h
/usr/include/mysql/mysql/service_mysql_string.h
/usr/include/mysql/mysql/service_thd_alloc.h
/usr/include/mysql/mysql/service_thd_wait.h
/usr/include/mysql/mysql/service_thread_scheduler.h
/usr/include/mysql/mysql/services.h
/usr/include/mysql/mysql/thread_pool_priv.h
/usr/include/mysql/mysql_com.h
/usr/include/mysql/mysql_com_server.h
/usr/include/mysql/mysql_embed.h
/usr/include/mysql/mysql_time.h
/usr/include/mysql/mysql_version.h
/usr/include/mysql/mysqld_ername.h
/usr/include/mysql/mysqld_error.h
/usr/include/mysql/plugin.h
/usr/include/mysql/plugin_audit.h
/usr/include/mysql/plugin_ftparser.h
/usr/include/mysql/plugin_validate_password.h
/usr/include/mysql/sql_common.h
/usr/include/mysql/sql_state.h
/usr/include/mysql/sslopt-case.h
/usr/include/mysql/sslopt-longopts.h
/usr/include/mysql/sslopt-vars.h
/usr/include/mysql/typelib.h
/usr/lib64/mysql
/usr/lib64/mysql/libmysqlclient.a
/usr/lib64/mysql/libmysqlclient_r.a
/usr/lib64/mysql/libmysqlservices.a
/usr/share/aclocal/mysql.m4
/usr/share/man/man1/comp_err.1.gz
/usr/share/man/man1/mysql_config.1.gz
[安装PostgreSQL]
略
[安装sysbench]
1. 下载
http://sourceforge.net/projects/sysbench/
2. 安装
tar -zxvf sysbench-0.4.12.tar.gz
cd sysbench-0.4.12
CFLAGS="-L/opt/pgsql9.2.4/lib -I/opt/pgsql9.2.4/include -lpq" ./configure --prefix=/opt/sysbench-0.4.12 --with-gnu-ld --with-mysql --with-pgsql --enable-dependency-tracking --with-mysql-includes=/usr/include/mysql --with-mysql-libs=/usr/lib64/mysql --with-pgsql-includes=/opt/pgsql9.2.4/include --with-pgsql-libs=/opt/pgsql9.2.4/lib
gmake
gmake install
查看sysbench oltp命令行选项 :
[root@db-172-16-3-33 bin]# ./sysbench --test=oltp help
sysbench 0.4.12: multi-threaded system evaluation benchmark
oltp options:
--oltp-test-mode=STRING test type to use {simple,complex,nontrx,sp} [complex]
--oltp-reconnect-mode=STRING reconnect mode {session,transaction,query,random} [session]
--oltp-sp-name=STRING name of store procedure to call in SP test mode []
--oltp-read-only=[on|off] generate only 'read' queries (do not modify database) [off]
--oltp-skip-trx=[on|off] skip BEGIN/COMMIT statements [off]
--oltp-range-size=N range size for range queries [100]
--oltp-point-selects=N number of point selects [10]
--oltp-simple-ranges=N number of simple ranges [1]
--oltp-sum-ranges=N number of sum ranges [1]
--oltp-order-ranges=N number of ordered ranges [1]
--oltp-distinct-ranges=N number of distinct ranges [1]
--oltp-index-updates=N number of index update [1]
--oltp-non-index-updates=N number of non-index updates [1]
--oltp-nontrx-mode=STRING mode for non-transactional test {select, update_key, update_nokey, insert, delete} [select]
--oltp-auto-inc=[on|off] whether AUTO_INCREMENT (or equivalent) should be used on id column [on]
--oltp-connect-delay=N time in microseconds to sleep after connection to database [10000]
--oltp-user-delay-min=N minimum time in microseconds to sleep after each request [0]
--oltp-user-delay-max=N maximum time in microseconds to sleep after each request [0]
--oltp-table-name=STRING name of test table [sbtest]
--oltp-table-size=N number of records in test table [10000]
--oltp-dist-type=STRING random numbers distribution {uniform,gaussian,special} [special]
--oltp-dist-iter=N number of iterations used for numbers generation [12]
--oltp-dist-pct=N percentage of values to be treated as 'special' (for special distribution) [1]
--oltp-dist-res=N percentage of 'special' values to use (for special distribution) [75]
General database options:
--db-driver=STRING specifies database driver to use ('help' to get list of available drivers)
--db-ps-mode=STRING prepared statements usage mode {auto, disable} [auto]
Compiled-in database drivers:
mysql - MySQL driver
pgsql - PostgreSQL driver
mysql options:
--mysql-host=[LIST,...] MySQL server host [localhost]
--mysql-port=N MySQL server port [3306]
--mysql-socket=STRING MySQL socket
--mysql-user=STRING MySQL user [sbtest]
--mysql-password=STRING MySQL password []
--mysql-db=STRING MySQL database name [sbtest]
--mysql-table-engine=STRING storage engine to use for the test table {myisam,innodb,bdb,heap,ndbcluster,federated} [innodb]
--mysql-engine-trx=STRING whether storage engine used is transactional or not {yes,no,auto} [auto]
--mysql-ssl=[on|off] use SSL connections, if available in the client library [off]
--myisam-max-rows=N max-rows parameter for MyISAM tables [1000000]
--mysql-create-options=STRING additional options passed to CREATE TABLE []
pgsql options:
--pgsql-host=STRING PostgreSQL server host [localhost]
--pgsql-port=N PostgreSQL server port [5432]
--pgsql-user=STRING PostgreSQL user [sbtest]
--pgsql-password=STRING PostgreSQL password []
--pgsql-db=STRING PostgreSQL database name [sbtest]
[问题处理]
1. 编译sysbench的问题1
Fatal server error:
Cannot establish any listening sockets - Make sure an X server isn't already running
../libtool: line 5172: : command not found
处理方法
[root@db-172-16-3-33 sysbench-0.4.12]# cp /usr/bin/libtool ./
cp: overwrite `./libtool'? y
2. 编译sysbench的问题2
drv_pgsql.c:29:22: error: libpq-fe.h: No such file or directory
drv_pgsql.c:104: error: expected specifier-qualifier-list before ‘Oid’
drv_pgsql.c: In function ‘pgsql_drv_connect’:
drv_pgsql.c:214: error: ‘PGconn’ undeclared (first use in this function)
drv_pgsql.c:214: error: (Each undeclared identifier is reported only once
drv_pgsql.c:214: error: for each function it appears in.)
drv_pgsql.c:214: error: ‘con’ undeclared (first use in this function)
drv_pgsql.c:223: error: ‘CONNECTION_OK’ undeclared (first use in this function)
drv_pgsql.c: In function ‘pgsql_drv_disconnect’:
drv_pgsql.c:242: error: ‘PGconn’ undeclared (first use in this function)
drv_pgsql.c:242: error: ‘con’ undeclared (first use in this function)
drv_pgsql.c:242: error: expected expression before ‘)’ token
drv_pgsql.c: In function ‘pgsql_drv_prepare’:
drv_pgsql.c:256: error: ‘PGconn’ undeclared (first use in this function)
drv_pgsql.c:256: error: ‘con’ undeclared (first use in this function)
drv_pgsql.c:256: error: expected expression before ‘)’ token
drv_pgsql.c:257: error: ‘PGresult’ undeclared (first use in this function)
drv_pgsql.c:257: error: ‘pgres’ undeclared (first use in this function)
drv_pgsql.c:335: error: ‘PGRES_COMMAND_OK’ undeclared (first use in this function)
drv_pgsql.c: In function ‘pgsql_drv_bind_param’:
drv_pgsql.c:358: error: ‘PGconn’ undeclared (first use in this function)
drv_pgsql.c:358: error: ‘con’ undeclared (first use in this function)
drv_pgsql.c:358: error: expected expression before ‘)’ token
drv_pgsql.c:359: error: ‘PGresult’ undeclared (first use in this function)
drv_pgsql.c:359: error: ‘pgres’ undeclared (first use in this function)
drv_pgsql.c:391: error: ‘pg_stmt_t’ has no member named ‘ptypes’
drv_pgsql.c:392: error: ‘pg_stmt_t’ has no member named ‘ptypes’
drv_pgsql.c:397: error: ‘pg_stmt_t’ has no member named ‘ptypes’
drv_pgsql.c:401: error: ‘pg_stmt_t’ has no member named ‘ptypes’
drv_pgsql.c:403: error: ‘PGRES_COMMAND_OK’ undeclared (first use in this function)
drv_pgsql.c:409: error: ‘pg_stmt_t’ has no member named ‘pvalues’
drv_pgsql.c:410: error: ‘pg_stmt_t’ has no member named ‘pvalues’
drv_pgsql.c:416: error: ‘pg_stmt_t’ has no member named ‘pvalues’
drv_pgsql.c:418: error: ‘pg_stmt_t’ has no member named ‘pvalues’
drv_pgsql.c:419: error: ‘pg_stmt_t’ has no member named ‘pvalues’
drv_pgsql.c:422: error: ‘pg_stmt_t’ has no member named ‘pvalues’
drv_pgsql.c:423: error: ‘pg_stmt_t’ has no member named ‘pvalues’
drv_pgsql.c: In function ‘pgsql_drv_execute’:
drv_pgsql.c:452: error: ‘PGconn’ undeclared (first use in this function)
drv_pgsql.c:452: error: ‘pgcon’ undeclared (first use in this function)
drv_pgsql.c:452: error: expected expression before ‘)’ token
drv_pgsql.c:453: error: ‘PGresult’ undeclared (first use in this function)
drv_pgsql.c:453: error: ‘pgres’ undeclared (first use in this function)
drv_pgsql.c:454: error: ‘ExecStatusType’ undeclared (first use in this function)
drv_pgsql.c:454: error: expected ‘;’ before ‘status’
drv_pgsql.c:478: error: ‘pg_stmt_t’ has no member named ‘pvalues’
drv_pgsql.c:482: error: ‘pg_stmt_t’ has no member named ‘pvalues’
drv_pgsql.c:488: error: ‘pg_stmt_t’ has no member named ‘pvalues’
drv_pgsql.c:489: error: ‘status’ undeclared (first use in this function)
drv_pgsql.c:490: error: ‘PGRES_TUPLES_OK’ undeclared (first use in this function)
drv_pgsql.c:490: error: ‘PGRES_COMMAND_OK’ undeclared (first use in this function)
drv_pgsql.c: In function ‘pgsql_drv_query’:
drv_pgsql.c:551: error: ‘PGconn’ undeclared (first use in this function)
drv_pgsql.c:551: error: ‘con’ undeclared (first use in this function)
drv_pgsql.c:552: error: ‘PGresult’ undeclared (first use in this function)
drv_pgsql.c:552: error: ‘pgres’ undeclared (first use in this function)
drv_pgsql.c:553: error: ‘ExecStatusType’ undeclared (first use in this function)
drv_pgsql.c:553: error: expected ‘;’ before ‘status’
drv_pgsql.c:558: error: ‘status’ undeclared (first use in this function)
drv_pgsql.c:559: error: ‘PGRES_TUPLES_OK’ undeclared (first use in this function)
drv_pgsql.c:559: error: ‘PGRES_COMMAND_OK’ undeclared (first use in this function)
drv_pgsql.c: In function ‘pgsql_drv_store_results’:
drv_pgsql.c:611: error: ‘PGresult’ undeclared (first use in this function)
drv_pgsql.c:611: error: ‘pgres’ undeclared (first use in this function)
drv_pgsql.c:614: error: expected expression before ‘)’ token
drv_pgsql.c: In function ‘pgsql_drv_free_results’:
drv_pgsql.c:636: error: ‘PGresult’ undeclared (first use in this function)
drv_pgsql.c:636: error: expected expression before ‘)’ token
drv_pgsql.c: In function ‘pgsql_drv_close’:
drv_pgsql.c:657: error: ‘pg_stmt_t’ has no member named ‘ptypes’
drv_pgsql.c:658: error: ‘pg_stmt_t’ has no member named ‘ptypes’
drv_pgsql.c:659: error: ‘pg_stmt_t’ has no member named ‘pvalues’
drv_pgsql.c:662: error: ‘pg_stmt_t’ has no member named ‘pvalues’
drv_pgsql.c:663: error: ‘pg_stmt_t’ has no member named ‘pvalues’
drv_pgsql.c:664: error: ‘pg_stmt_t’ has no member named ‘pvalues’
gmake[3]: *** [libsbpgsql_a-drv_pgsql.o] Error 1
gmake[3]: Leaving directory `/opt/soft_bak/sysbench-0.4.12/sysbench/drivers/pgsql'
gmake[2]: *** [all-recursive] Error 1
gmake[2]: Leaving directory `/opt/soft_bak/sysbench-0.4.12/sysbench/drivers'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/opt/soft_bak/sysbench-0.4.12/sysbench'
gmake: *** [all-recursive] Error 1
解决办法 : 编译时指定CFLAGS
CFLAGS="-L/opt/pgsql9.2.4/lib -I/opt/pgsql9.2.4/include -lpq" ./configure --prefix=/opt/sysbench-0.4.12 --with-gnu-ld --with-mysql --with-pgsql --enable-dependency-tracking --with-mysql-includes=/usr/include/mysql --with-mysql-libs=/usr/lib64/mysql --with-pgsql-includes=/opt/pgsql9.2.4/include --with-pgsql-libs=/opt/pgsql9.2.4/lib
3. 编译sysbench的问题3
/usr/lib64/mysql/libmysqlclient_r.a(dsa.cpp.o):/pb2/build/sb_0-9099207-1367226680.09/rpm/BUILD/mysql-5.6.11/mysql-5.6.11/extra/yassl/taocrypt/include/misc.hpp:102: more undefined references to `operator delete[](void*)' follow
collect2: ld returned 1 exit status
gmake[2]: *** [sysbench] Error 1
gmake[2]: Leaving directory `/opt/soft_bak/sysbench-0.4.12/sysbench'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/opt/soft_bak/sysbench-0.4.12/sysbench'
gmake: *** [all-recursive] Error 1
解决办法, 使用低版本mysql 开发包 :
[root@db-172-16-3-33 sysbench-0.4.12]# rpm -e MySQL-devel-5.6.11-2.rhel5
[root@db-172-16-3-33 soft_bak]# rpm -ivh MySQL-devel-community-5.1.69-1.rhel5.x86_64.rpm
Preparing... ########################################### [100%]
1:MySQL-devel-community ########################################### [100%]
时间: 2024-10-17 09:53:29