时间:2021-07-01 10:21:17 帮助过:38人阅读
新建一个逻辑卷(过程见链接),并将其挂载至/mydata/data目录, 做为mysql数据的存放目录。
http://858004880.blog.51cto.com/7265424/1759317
1.删除系统原来的mysql用户家目录 [root@web ~]# userdel -r mysql 2.创建mysql系统用户组 [root@web ~]# groupadd -r mysql 3.添加mysql用户到mysql组并且指明路径 [root@web ~]# useradd -g mysql -r -s/sbin/nologin -M -d /mydata/data mysql useradd[options] LOGIN -g GID:指明用户所属基本组,可为组名,也可以GID; -d/PATH/TO/HOME_DIR: 以指定的路径为家目录; -s SHELL: 指明用户的默认shell程序,可用列表在/etc/shells文件中; -r: 创建系统用户 -M: 不自动创建用户的家目录 [root@web ~]# cat /etc/passwd mysql:x:498:499::/mydata/data:/sbin/nologin 4.修改数据文件属主: [root@web ~]# chown -R mysql:mysql/mydata/data/ [root@web ~]# ll /mydata/ total 4 drwxr-xr-x3 mysql mysql 4096 Apr 1 16:21 data
3.1安装所需要的 gcc gcc-c++ ncurses-devel perl库:
[root@web tools]# yum -y install gcc gcc-c++ ncurses-devel perl
3.2安装cmrk
[root@web tools]# wget https://cmake.org/files/v3.5/cmake-3.5.0.tar.gz [root@web tools]# tar xf cmake-3.5.0.tar.gz [root@web tools]# cd cmake-3.5.0 [root@web cmake-3.5.0]# ./bootstrap [root@webcmake-3.5.0]# make&&make install
3.3下载mysql5.6.29
http://dev.mysql.com/downloads/mysql/5.6.html
3.4下载解压:
[root@web tools]# wget http://cdn.mysql.com//Downloads/MySQL-5.5/mysql-5.5.48.tar.gz [root@webtool]# tar xf mysql-5.5.48.tar.gz.1
4、编译安装:
[root@web tool]# cdmysql-5.5.48 [root@webmysql-5.5.48]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mydata/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock-DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci # make && make install
5、修改mysql目录所有者和组
[root@web mysql-5.5.48]# cd /usr/local/mysql/ [root@webmysql]# chown -R mysql:mysql .
6、初始化mysql数据库
# scripts/mysql_install_db--basedir=/usr/local/mysql --datadir=/mydata/data --user=mysq
7、为mysql提供主配置文件my.cnf:
[root@web mysql]# cp support-files/my-large.cnf/etc/my.cnf
# 并修改此文件中thread_concurrency的值为你的CPU个数乘以2,比如这里使用如下行:
thread_concurrency = 2
# 另外还需要添加如下行指定mysql数据文件的存放位置:
datadir = /mydata/data
[root@web mysql]# vim /etc/my.cnf [mysqld] # Try number of CPU‘s*2 forthread_concurrency thread_concurrency = 2 datadir = /mydata/data #下面两行代码必须添加: innodb_file_per_table = 1 skip_name_resolve = 1
8、为mysql提供sysv服务脚本:
[root@web mysql]# cpsupport-files/mysql.server /etc/rc.d/init.d/mysqld [root@webmysql]# chmod +x /etc/rc.d/init.d/mysqld
9、添加至服务列表:
[root@web mysql]# chkconfig --add mysqld [root@webmysql]# chkconfig mysqld on
而后就可以启动服务测试使用了。
为了使用mysql的安装符合系统使用规范,并将其开发组件导出给系统使用,这里还需要进行如下步骤:
10、输出mysql的man手册至man命令的查找路径:
编辑/etc/man.config,添加如下行即可:
MANPATH /usr/local/mysql/man
[root@web mysql]# vim /etc/man.config # /var/cache/man/.../[locale/]catx/page.x. # The keyword FHSwill cause this behaviour (and overrides FSSTND). # Explicitly givencatdirs override. # # FSSTND FHS # # This file is alsoread by man in order to find how to call nroff, less, etc., # and to determinethe correspondence between extensions and decompressors. # # MANBIN /usr/local/bin/man # # Every automaticallygenerated MANPATH includes these fields # MANPATH /usr/man MANPATH /usr/share/man MANPATH /usr/local/man MANPATH /usr/local/share/man MANPATH /usr/X11R6/man MANPATH/usr/local/mysql/man
11、输出mysql的头文件至系统头文件路径/usr/include:
这可以通过简单的创建链接实现:
# ln -sv /usr/local/mysql/include /usr/include/mysql
12、输出mysql的库文件给系统库查找路径:
# echo ‘/usr/local/mysql/lib‘ >/etc/ld.so.conf.d/mysql.conf
而后让系统重新载入系统库:
# ldconfig
13、修改PATH环境变量,让系统可以直接使用mysql的相关命令。
编辑/etc/profile,在最后添加:
[root@web mysql]# vim /etc/profile PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH exportPATH
保存退出;然后执行:
[root@web mysql]# source/etc/profile
环境变量添加成功
14、输入mysql命令:
[root@web mysql]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.5.48-log Source distribution Copyright (c) 2000, 2016, Oracle and/or itsaffiliates. All rights reserved. Oracle is a registered trademark of OracleCorporation and/or its affiliates. Other names may be trademarks of theirrespective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clearthe current input statement. mysql>
说明mysql安装成功!
15、修改MySQL用户root的密码
默认为空密码登录:
# mysql -u root –p
设置root密码: mysql> SET PASSWORD = PASSWORD(‘123456‘);
修改密码为test123: mysql> SET PASSWORD FOR‘root‘@‘localhost‘ = PASSWORD(‘test123‘); Query OK, 0 rows affected(0.00 sec) mysql> SET PASSWORD FOR‘root‘@‘127.0.0.1‘ = PASSWORD(‘test123‘); Query OK, 0 rows affected(0.00 sec) mysql> FLUSH PRIVILEGES; QueryOK, 0 rows affected (0.00 sec)
查看用户:
mysql> SELECT DISTINCT CONCAT(‘User:‘‘‘,user,‘‘‘@‘‘‘,host,‘‘‘;‘) AS query FROM mysql.user; +---------------------------------+ | query | +---------------------------------+ | User: ‘phpmyadmin‘@‘127.0.0.1‘; | | User: ‘root‘@‘127.0.0.1‘; | | User: ‘root‘@‘::1‘; | | User: ‘‘@‘localhost‘; | | User: ‘phpmyadmin‘@‘localhost‘; | | User: ‘root‘@‘localhost‘; | | User: ‘‘@‘web.example.com‘; | | User: ‘root‘@‘web.example.com‘; | +---------------------------------+ 8 rows in set (0.04 sec) mysql>
mysql安装完成!
下一篇:四、编译安装php-5.5.34
本文出自 “汛熙时空” 博客,请务必保留此出处http://858004880.blog.51cto.com/7265424/1763177
三、编译安装mysql-5.5.33
标签:编译安装mysql5.5