一般我们安装mysql采用二进制安装的方式就足以满足我们的生产环境了,不过需要我们配置my.cnf文件
[iyunv@HE1 ~]#tar xvf mysql-5.6.16-linux-glibc2.5-x86_64.tar.gz mv mysql-5.6.16-linux-glibc2.5-x86_64 /usr/local/mysql 1
2
3
4
5
6
7
8
9
| [iyunv@HE1mysql]#groupadd mysql -g 512
[iyunv@HE1mysql]#useradd-u 512 -g mysql -s /sbin/nologin -d /home/mysql mysql
[iyunv@HE1mysql]#mkdir-p /data/mysql
[iyunv@HE1mysql]#mkdir-p /log/mysql
[iyunv@HE1mysql]#chown-R mysql:mysql /data/mysql
[iyunv@HE1mysql]#chown -R mysql:mysql/usr/local/mysql
[iyunv@HE1mysql]#chown-R mysql:mysql /log
[iyunv@HE1mysql]#echo "export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib">>/etc/profile
[iyunv@HE1mysql]#source /etc/profile
|
[iyunv@HE1~]# cat /etc/my.cnf 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
| [client]
#port =3306
#socket =/tmp/mysql.sock
#default-character-set=utf8
[mysql]
#default-character-set=utf8
[mysqld]
port =3306
socket =/tmp/mysql.sock
basedir =/usr/local/mysql
datadir =/data/mysql
open_files_limit = 3072
back_log= 103
max_connections= 512
max_connect_errors= 100000
table_open_cache= 512
external-locking= FALSE
max_allowed_packet= 32M
sort_buffer_size= 2M
join_buffer_size= 2M
thread_cache_size= 51
query_cache_size= 32M
tmp_table_size= 96M
max_heap_table_size= 96M
slow_query_log= 1
slow_query_log_file= /data/mysql/slow.log
log-error= /data/mysql/error.log
long_query_time= 0.05
server-id= 1
log-bin =/data/mysql/mysql-bin
sync_binlog= 1
binlog_cache_size= 4M
max_binlog_cache_size= 8M
max_binlog_size= 1024M
expire_logs_days= 7
key_buffer_size= 32M
read_buffer_size= 1M
read_rnd_buffer_size= 16M
bulk_insert_buffer_size= 64M
character-set-server=utf8
default-storage-engine= InnoDB
binlog_format=row
#gtid_mode=on
#log_slave_updates=1
#enforce_gtid_consistency=1
transaction_isolation= REPEATABLE-READ
innodb_additional_mem_pool_size= 16M
innodb_buffer_pool_size= 1434M
innodb_data_file_path= ibdata1:1024M:autoextend
innodb_flush_log_at_trx_commit= 1
innodb_log_buffer_size= 16M
innodb_log_file_size= 256M
innodb_log_files_in_group= 2
innodb_max_dirty_pages_pct= 50
innodb_file_per_table= 1
innodb_locks_unsafe_for_binlog= 0
[mysqldump]
quick
max_allowed_packet= 32M
|
[iyunv@HE1bin]# ./mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql--defaults-file=/etc/my.cnf --user=mysql
8.进到bin下./mysqld_safe--help看下 [iyunv@HE1bin]# ./mysqld_safe --defaults-file=/etc/my.cnf &
1
2
3
4
5
6
7
8
9
10
11
| mysql>delete from mysql.user where user!='root' or host!='localhost';
Query OK,5 rows affected (0.01 sec)
mysql>update user set password=password('root123') where user='root';
Query OK,1 row affected (0.00 sec)
mysql>grant select,delete,update,insert on *.* to helei@'192.168.1.%' identified by 'root123';
Query OK,0 rows affected (0.00 sec)
mysql>grant all privileges on *.* to root@'192.168.1.%' identified by 'root123';
Query OK,0 rows affected (0.28 sec)
mysql>flush privileges;
Query OK,0 rows affected (0.00 sec)
|
mysql>select user,host,password from mysql.user; +-------+-------------+-------------------------------------------+ |user | host | password | +-------+-------------+-------------------------------------------+ |root | localhost | *A9F635AE07EC0944EFFE52FD0A86327B98ADDED7| |root | 192.168.1.% |*A9F635AE07EC0944EFFE52FD0A86327B98ADDED7 | | helei |192.168.1.% | *A9F635AE07EC0944EFFE52FD0A86327B98ADDED7 | +-------+-------------+-------------------------------------------+ 3 rows inset (0.00 sec)
[iyunv@HE1bin]# ./mysqladmin -uroot -p shutdown Enterpassword: 16031700:53:52 mysqld_safe mysqld from pid file /data/mysql/HE1.pid ended [1]+ Done ./mysqld_safe--defaults-file=/etc/my.cnf
配置mysql [iyunv@HE1mysql]# cp support-files/mysql.server /etc/init.d/mysqld chmod700 /etc/init.d/mysqld chkconfig --add mysqld chkconfig--level 2345 mysqld on
[iyunv@HE1~]# /etc/init.d/mysqld status ERROR! MySQL is not running [iyunv@HE1~]# /etc/init.d/mysqld start StartingMySQL.. SUCCESS!
TCP和套接字连接方式 [iyunv@HE1 bin]#mysql -p -S /data/mysql.sock Enter password: Welcome to the MySQLmonitor. Commands end with ; or \g. Your MySQLconnection id is 6 Server version:5.6.16-log MySQL Community Server (GPL)
Copyright (c) 2000,2014, Oracle and/or its affiliates. All rights reserved.
Oracle is aregistered trademark of Oracle Corporation and/or its affiliates. Othernames may be trademarks of their respective owners.
Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
mysql> quit Bye
[iyunv@HE1~]# /etc/init.d/mysqld stop Shuttingdown MySQL.. SUCCESS! [iyunv@HE1~]# /etc/init.d/mysqld status ERROR! MySQL is not running
|