1、安装下载好的4个RPM包
rpm -ivh Percona-Server-shared-56-5.6.16-rel64.0.el6.x86_64.rpm
rpm -ivh Percona-Server-client-56-5.6.16-rel64.0.el6.x86_64.rpm
rpm -ivh Percona-Server-server-56-5.6.16-rel64.0.el6.x86_64.rpm
rpm -ivh Percona-Server-devel-56-5.6.16-rel64.0.el6.x86_64.rpm
2、找到MySQL的配置文件,根据此配置文件的内容创建相关目录和资源
find / -iname my.cnf
vi /etc/my.cnf
[client]
port = 3306
socket = /my/log/mysql.sock
[mysql]
default-character-set = utf8
[mysqld]
# file
datadir = /my/data
pid-file= /my/log/mysql.pid
log_error=/my/log/mysql.err
port = 3306
socket = /my/log/mysql.sock
character_set_server = utf8
#skip-grant-tables
slow_query_log = 1
slow_query_log_file = /my/log/slowq.log
long_query_time = 1
# temp
max_tmp_tables = 64
max_heap_table_size = 1G
tmp_table_size = 512M
slave_load_tmpdir = /my/log
tmpdir = /my/log
# session
back_log = 8192
skip-name-resolve
max_allowed_packet = 32M
max_connections = 16000
max_connect_errors = 10000
wait_timeout = 28800
binlog_cache_size = 1M
table_open_cache = 1024
thread_concurrency =
thread_cache_size = 128
thread_handling = pool-of-threads
thread_pool_high_prio_mode = none
thread_pool_idle_timeout = 28800
thread_pool_oversubscribe = 20
#max_statement_time = 5000
query_cache_type = 0
query_cache_size = 0
key_buffer_size = 128M
myisam_sort_buffer_size = 16M
read_buffer_size = 8M
read_rnd_buffer_size = 4M
sort_buffer_size = 16M
join_buffer_size = 16M
# innodb
default_storage_engine = InnoDB
innodb_data_home_dir = /my/log
innodb_data_file_path=ibdata1:256M:autoextend
innodb_log_group_home_dir = /my/log
innodb_log_files_in_group = 4
innodb_log_file_size = 256M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 2
innodb_flush_method = O_DIRECT
innodb_lock_wait_timeout = 50
#innodb_thread_concurrency = 16
innodb_buffer_pool_size = 3G
innodb_additional_mem_pool_size = 20M
innodb_io_capacity = 1500
innodb_use_native_aio = 1
innodb_file_per_table = 1
innodb_open_files = 3000
innodb_print_all_deadlocks = 1
# others
memlock = 1
performance_schema = 0
# replication
server-id =5248
log-bin = /my/log/mysql-bin
#binlog-ignore-db=mysql
binlog_format = mixed
expire_logs_days = 7
relay_log = /my/log/relay-bin
#replicate_ignore_db = mysql
#slave_skip_errors = 1062
log_slave_updates = 1
skip-slave-start
#read_only = 1 ---若无主从关系,或者有主从而是主不是从,需要把此行注释掉,不要只读
#sync_binlog = 1
[mysqldump]
default-character-set = utf8 ---MySQL数据库只用utf8语音
改buffer的大小(60%原则)innodb_buffer_pool_size=(3)G ------这里只给了3G
3、查看MySQL相关进程
ps -ef | grep mysql
ps -ef | grep mysqld
4、初始化数据库
找到mysql_install_db文件:find / -name mysql_install_db;如果用find命令找不到,可以直接在命令行输入mysql+Tab
用命令:mysql_install_db --user=mysql --defaults-file=/etc/my.cnf 初始化mysql数据库[root@test-5-248 etc]# mysql_install_db --user=mysql --defaults-file=/etc/my.cnf
Installing MySQL system tables...2018-05-08 11:18:48 0 [Warning] option 'thread_concurrency': unsigned value 0 adjusted to 1
2018-05-08 11:18:48 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
OK
Filling help tables...2018-05-08 11:18:54 0 [Warning] option 'thread_concurrency': unsigned value 0 adjusted to 1
2018-05-08 11:18:54 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
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 192.168.5.248 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 mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
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
WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
[root@test-5-248 etc]# cd /my/data/
[root@test-5-248 data]# ls
mysql performance_schema test ---在初始化的过程中可以到 /my/data/目录看下,此目录的文件会增多,直到文件有4个
[root@test-5-248 data]# cd ..
[[root@test-5-248 my]# cd log/
[root@test-5-248 log]# ls
ibdata1 ib_logfile0 ib_logfile1 ib_logfile2 ib_logfile3 mysql-bin.000001 mysql-bin.000002 mysql-bin.index mysql.err
6、开启MySQL服务
[root@test-5-248 log]# /etc/init.d/mysql start ---service mysql start命令也可以启动MySQL的服务Starting MySQL (Percona Server).. SUCCESS!
7、登录数据库
服务启动后再去改数据库的root用户登录密码,首次登录时是没有密码的,用mysql命令进入数据库,再改
[root@test-5-248 ~]# mysql
mysql> set password for 'root'@'localhost'=password('123');
Query OK, 0 rows affected (0.00 sec)登录数据库:mysql -u root -p 提示输入密码,若用明文密码登录,-p后面不要有空格,如:mysql -u root -p123