CentOS 6.5下二进制安装 MySQL 5.6
CentOS 6.5 二进制安装MySQL 5.6
1:查看系统版本
1
2
|
[root@10-4-5-9 mysql]# cat /etc/redhat-release CentOS release 6.5 (Final) |
2:下载MySQL5.6二进制包
3:添加用户和组
1
2
|
#groupadd mysql #useradd -g mysql mysql |
4:安装mysql到/usr/local/mysql下
1
2
3
4
5
6
7
|
#cd /usr/ local #tar zxvf /{MySQL5.6_path}/mysql-{version}.tar.gz 例如我的配置路径为: #cd /usr/ local #tar zxvf /root/mysql-5.6.20-linux-glibc2.5-i686.tar.gz |
5:修改解压后文件夹名为 mysql
1
|
#mv mysql-5.6.20-linux-glibc2.5-i686 mysql |
6:修改mysql的各级文件夹和文件的创建者、创建组为mysql(注意语句后面有个.)
1
2
3
|
cd mysql chown -R mysql . chgrp -R mysql . |
7:至此mysql已经安装完了,但还需要初始化,初始化mysql表、test表、infomation表等。
1
|
#scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data<br><br> |
1
|
#cp support-files/mysql.server /etc/init.d/mysqld |
1
2
3
|
--user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data |
1
2
|
PS:该步骤有可能会报错误 安装需要的包即可:libstdc++.so.6和libaio.so.1和libncurses.so.5 |
8:修改配置文件
1
2
3
|
[root@10-4-5-9 mysql]# cp my.cnf /etc/my.cnf /usr/ local /mysql [root@10-4-5-9 mysql]# vi /etc/my.cnf |
1
2
3
4
5
6
|
[mysqld]中添加: basedir = /usr/ local /mysql datadir = /usr/ local /mysql/data port = 3306 server_id = 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
|
[mysqld] datadir = /data/mysql socket = /tmp/mysql .sock pid- file = /data/logs/mysql/mysql .pid user = mysql port = 3306 default_storage_engine = InnoDB # InnoDB #innodb_buffer_pool_size = 128M #innodb_log_file_size = 48M innodb_file_per_table = 1 innodb_flush_method = O_DIRECT # MyISAM #key_buffer_size = 48M # character-set character- set -server=utf8 collation-server=utf8_general_ci # name-resolve skip-host-cache skip-name-resolve # LOG log_error = /data/logs/mysql/mysql-error .log long_query_time = 1 slow-query-log slow_query_log_file = /data/logs/mysql/mysql-slow .log # Others explicit_defaults_for_timestamp= true #max_connections = 500 open_files_limit = 65535 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES [client] socket = /tmp/mysql .sock port = 3306 |
Note:
被注释掉的部分语句,需要结合业务和硬件资源进行修改,所以先占位,使用默认值即可。my.cnf文件中不能出现拼写错误,否则,接下来启动会出现很多意想不到的错误,如果出现无法启动请参看:mysql-error.log文件。权限设置不当也会导致启动失败。
启动前,再次确认一遍权限:
很有可能现在my.cnf的权限不是mysql,同时检查一下/etc/my.cnf是否存在,如果存在则删除!!!
9:启动mySQL服务
1
|
#ln -s /usr/ local /mysql/bin/mysql /usr/bin |
1
|
#service mysqld start |
10:登陆MySQL并且删除空用户
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
mysql> SELECT user ,host, password FROM mysql. user ; + ------+-----------+----------+ | user | host | password | + ------+-----------+----------+ | root | localhost | | | root | 10-4-5-9 | | | root | 127.0.0.1 | | | root | ::1 | | | | localhost | | | | 10-4-5-9 | | + ------+-----------+----------+ 6 rows in set (0.00 sec) mysql> UPDATE mysql. user set password = PASSWORD ( 'gechong' ) WHERE user = 'root' ; mysql> DROP USER '' @localhost; mysql> FLUSH PRIVILEGES ; |
转载