Linux环境安装Mysql数据库(手工+自动两种 详细版)
2017-08-19 16:39
429 查看
参考:
http://www.linuxdiyf.com/viewarticle.php?id=65598
http://bestchenwu.iteye.com/blog/1166998
第一种安装方式:
安装MySQL后,需要初始化 授权表、启动服务器,并确保服务器工作正常。你还要让服务器随系统的启动和停止自动启动和停止。应当为授权表中的账户指定密码。在某些安装中,该程序自动运行。
1、添加mysql用户组以及用户
groupadd mysql
useradd -g mysql mysql
2、解压mysql 并制定安装目录
cd /root/software/
tar xvzf mysql-5.1.68.tar.gz
cd mysql-5.1.68
3、configure
第一次配置 configure
./configure –prefix=/usr/local/mysql/ –with-server-suffix=-unionread-edition –enable-assembler –enable-local-infile –enable-thread-safe-client –with-charset=utf8 –with-extra-charsets=gbk,gb2312,utf8,ascii –with-readline –with-ssl –with-embedded-server –with-pthread –with-mysqld-user=mysql –with-mysqld-ldflags=-all-static –with-client-ldflags=-all-static –with-plugins=partition,innobase,innodb_plugin
报错:
checking for tgetent in -lncursesw… no
checking for tgetent in -lncurses… no
checking for tgetent in -lcurses… no
checking for tgetent in -ltermcap… no
checking for tgetent in -ltinfo… no
checking for termcap functions library… configure: error: No curses/termcap library found
**问题:**configure时遇到缺少ncurses依赖包
解决:
查看nucrses并安装ncurses依赖包
yum list|grep ncurses
yum -y install ncurses-devel
安装完成以后重新配置 configure
./configure –prefix=/usr/local/mysql/ –with-server-suffix=-unionread-edition –enable-assembler –enable-local-infile –enable-thread-safe-client –with-charset=utf8 –with-extra-charsets=gbk,gb2312,utf8,ascii –with-readline –with-ssl –with-embedded-server –with-pthread –with-mysqld-user=mysql –with-mysqld-ldflags=-all-static –with-client-ldflags=-all-static –with-plugins=partition,innobase,innodb_plugin
Thank you for choosing MySQL! mysql安装的第一步成功
4、make && make install
报错:
make[1]: Entering directory
4000
ot/software/mysql-5.1.68/mysys’
make: * [all-recursive] Error 1
问题:g++ not found 。
对比查看发现GCC已经安装但缺少g++,所以make时报错。
安装gcc-c++
[root@open2 ~/software]# yum -y install gcc-c++
第三次 ./configure
./configure –prefix=/usr/local/mysql/ –with-server-suffix=-unionread-edition –enable-assembler –enable-local-infile –enable-thread-safe-client –with-charset=utf8 –with-extra-charsets=gbk,gb2312,utf8,ascii –with-readline –with-ssl –with-embedded-server –with-pthread –with-mysqld-user=mysql –with-mysqld-ldflags=-all-static –with-client-ldflags=-all-static –with-plugins=partition,innobase,innodb_plugin
make && make install
漫长的等待。
5、初始化授权表:
/usr/local/mysql/bin/mysql_install_db –user=mysql –datadir=/var/lib/mysql/
copy配置文件:
cp /usr/local/mysql/share/my-medium.cnf /etc/my.cnf
6、启动mysql服务
/usr/local/mysql/bin/mysqld_safe &
设置启动服务
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
chkconfig –add mysqld
chkconfig –level 345 mysqld on
复制mysql启动到用户path下
cp /usr/local/mysql/bin/mysql /usr/bin/mysql
启动mysql
service mysqld start
键入mysql 或者 全路径 /usr/local/mysql/bin/mysql
可以登陆了。
7、修改root密码
/usr/local/mysql/bin/mysqladmin -uroot password XXXXXX
再次登陆
mysql -uroot -p
第二种方式 rpm安装包手动安装:
1)软件包:
MySQL-server-community-5.1.54-1.rhel5.x86_64.rpm
MySQL-client-community-5.1.54-1.rhel5.x86_64.rpm
2)安装命令:
rpm -ivh MySQL-server-community-5.1.54-1.rhel5.x86_64.rpm
rpm -ivh MySQL-client-community-5.1.54-1.rhel5.x86_64.rpm
执行安装时报错:
[root@open2 ~/software]# rpm -ivh MySQL-server-community-5.1.54-1.rhel5.x86_64.rpm
Preparing… ########################################### [100%]
file /usr/share/mysql/spanish/errmsg.sys from install of MySQL-server-community-5.1.54-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
file /usr/share/mysql/swedish/errmsg.sys from install of MySQL-server-community-5.1.54-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
file /usr/share/mysql/ukrainian/errmsg.sys from install of MySQL-server-community-5.1.54-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
错误提示server与mysql-libs-5.1.66包冲突。
解决思路,先移除冲突的libs包,在进行安装
[root@open2 ~/software]# rpm -qa |grep mysql
mysql-libs-5.1.66-2.el6_3.x86_64
[root@open2 ~/software]# yum -y remove mysql-libs-5.1.66*
[root@open2 ~/software]# rpm -ivh MySQL-server-community-5.1.54-1.rhel5.x86_64.rpm
成功。
http://www.linuxdiyf.com/viewarticle.php?id=65598
http://bestchenwu.iteye.com/blog/1166998
第一种安装方式:
安装MySQL后,需要初始化 授权表、启动服务器,并确保服务器工作正常。你还要让服务器随系统的启动和停止自动启动和停止。应当为授权表中的账户指定密码。在某些安装中,该程序自动运行。
1、添加mysql用户组以及用户
groupadd mysql
useradd -g mysql mysql
2、解压mysql 并制定安装目录
cd /root/software/
tar xvzf mysql-5.1.68.tar.gz
cd mysql-5.1.68
3、configure
第一次配置 configure
./configure –prefix=/usr/local/mysql/ –with-server-suffix=-unionread-edition –enable-assembler –enable-local-infile –enable-thread-safe-client –with-charset=utf8 –with-extra-charsets=gbk,gb2312,utf8,ascii –with-readline –with-ssl –with-embedded-server –with-pthread –with-mysqld-user=mysql –with-mysqld-ldflags=-all-static –with-client-ldflags=-all-static –with-plugins=partition,innobase,innodb_plugin
报错:
checking for tgetent in -lncursesw… no
checking for tgetent in -lncurses… no
checking for tgetent in -lcurses… no
checking for tgetent in -ltermcap… no
checking for tgetent in -ltinfo… no
checking for termcap functions library… configure: error: No curses/termcap library found
**问题:**configure时遇到缺少ncurses依赖包
解决:
查看nucrses并安装ncurses依赖包
yum list|grep ncurses
yum -y install ncurses-devel
安装完成以后重新配置 configure
./configure –prefix=/usr/local/mysql/ –with-server-suffix=-unionread-edition –enable-assembler –enable-local-infile –enable-thread-safe-client –with-charset=utf8 –with-extra-charsets=gbk,gb2312,utf8,ascii –with-readline –with-ssl –with-embedded-server –with-pthread –with-mysqld-user=mysql –with-mysqld-ldflags=-all-static –with-client-ldflags=-all-static –with-plugins=partition,innobase,innodb_plugin
Thank you for choosing MySQL! mysql安装的第一步成功
4、make && make install
报错:
make[1]: Entering directory
/root/software/mysql-5.1.68/mysys' source='my_new.cc' object='my_new.o' libtool=no \ DEPDIR=.deps depmode=none /bin/sh ../depcomp \ g++ -DDEFAULT_BASEDIR=\"/home/mysql\" -DMYSQL_DATADIR="\"/home/mysql/var\"" -DDEFAULT_CHARSET_HOME="\"/home/mysql\"" -DSHAREDIR="\"/home/mysql/share/mysql\"" -DDEFAULT_HOME_ENV=MYSQL_HOME -DDEFAULT_GROUP_SUFFIX_ENV=MYSQL_GROUP_SUFFIX -DDEFAULT_SYSCONFDIR="\"/home/mysql/etc\"" -DHAVE_CONFIG_H -I. -I../include -I../include -I../include -I. -O -fno-implicit-templates -fno-exceptions -fno-rtti -c -o my_new.o my_new.cc ../depcomp: line 571: exec: g++: not found make[1]: *** [my_new.o] Error 127 make[1]: Leaving directory/ro
4000
ot/software/mysql-5.1.68/mysys’
make: * [all-recursive] Error 1
问题:g++ not found 。
对比查看发现GCC已经安装但缺少g++,所以make时报错。
安装gcc-c++
[root@open2 ~/software]# yum -y install gcc-c++
第三次 ./configure
./configure –prefix=/usr/local/mysql/ –with-server-suffix=-unionread-edition –enable-assembler –enable-local-infile –enable-thread-safe-client –with-charset=utf8 –with-extra-charsets=gbk,gb2312,utf8,ascii –with-readline –with-ssl –with-embedded-server –with-pthread –with-mysqld-user=mysql –with-mysqld-ldflags=-all-static –with-client-ldflags=-all-static –with-plugins=partition,innobase,innodb_plugin
make && make install
漫长的等待。
5、初始化授权表:
/usr/local/mysql/bin/mysql_install_db –user=mysql –datadir=/var/lib/mysql/
copy配置文件:
cp /usr/local/mysql/share/my-medium.cnf /etc/my.cnf
6、启动mysql服务
/usr/local/mysql/bin/mysqld_safe &
设置启动服务
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
chkconfig –add mysqld
chkconfig –level 345 mysqld on
复制mysql启动到用户path下
cp /usr/local/mysql/bin/mysql /usr/bin/mysql
启动mysql
service mysqld start
键入mysql 或者 全路径 /usr/local/mysql/bin/mysql
可以登陆了。
7、修改root密码
/usr/local/mysql/bin/mysqladmin -uroot password XXXXXX
再次登陆
mysql -uroot -p
第二种方式 rpm安装包手动安装:
1)软件包:
MySQL-server-community-5.1.54-1.rhel5.x86_64.rpm
MySQL-client-community-5.1.54-1.rhel5.x86_64.rpm
2)安装命令:
rpm -ivh MySQL-server-community-5.1.54-1.rhel5.x86_64.rpm
rpm -ivh MySQL-client-community-5.1.54-1.rhel5.x86_64.rpm
执行安装时报错:
[root@open2 ~/software]# rpm -ivh MySQL-server-community-5.1.54-1.rhel5.x86_64.rpm
Preparing… ########################################### [100%]
file /usr/share/mysql/spanish/errmsg.sys from install of MySQL-server-community-5.1.54-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
file /usr/share/mysql/swedish/errmsg.sys from install of MySQL-server-community-5.1.54-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
file /usr/share/mysql/ukrainian/errmsg.sys from install of MySQL-server-community-5.1.54-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
错误提示server与mysql-libs-5.1.66包冲突。
解决思路,先移除冲突的libs包,在进行安装
[root@open2 ~/software]# rpm -qa |grep mysql
mysql-libs-5.1.66-2.el6_3.x86_64
[root@open2 ~/software]# yum -y remove mysql-libs-5.1.66*
[root@open2 ~/software]# rpm -ivh MySQL-server-community-5.1.54-1.rhel5.x86_64.rpm
成功。
相关文章推荐
- Linux环境安装Mysql数据库(手工+自动两种 详细版)
- linux安装配置java环境变量(详细)
- RedHat5.2下Linux Oracle 10g ASM 安装详细实录-第一篇-环境准备
- 全世界最详细的图形化VMware中linux环境下oracle安装(三)【weber出品必属精品】
- lamp环境安装(linux apache mysql php)步骤及详细解说
- linux环境下oracle 10 R2安装详细步骤
- VMware虚拟机下搭建全自动安装linux系统环境配置
- Linux环境安装Mysql数据库的三种方式之一:二进制包方式安装
- 在Linux环境下安装部署MySQL数据库系统实例
- Linux下自动备份MySQL数据库详细操作步骤(转载)
- Linux环境下安装部署MySQL数据库系统实例
- 在Linux下安装JDK及环境设置的两种方法
- 生产环境Mysql数据库备份脚本,Linux下网站数据定期自动备份与删除脚本,Windows下备份网站目录和数据库
- 全世界最详细的图形化VMware中linux环境下oracle安装(二)【weber出品必属精品】
- Linux负载均衡环境搭建-1 Linux下安装Nginx详细图解教程
- 【linux】Linux iptables 详细介绍安装环境及配置方法
- Linux环境下MySQL(二进制)自动安装脚本
- linux 手工自动安装mysql最新版本tar包步骤(随意指定安装目录且不分散)
- linux安装oracle 11g环境搭配自动安装脚本