yum remove mysql
wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
tar -xvf cmake-2.8.4.tar.gz
cd cmake-2.8.4;
./bootstrap
---------------------------------------------
CMake 2.8.4, Copyright 2000-2009 Kitware, Inc.
---------------------------------------------
Error when bootstrapping CMake:
Cannot find appropriate C compiler on this system.
Please specify one using environment variable CC.
See cmake_bootstrap.log for compilers attempted.
---------------------------------------------
Log of errors: /usr/local/src/cmake-2.8.4/Bootstrap.cmk/cmake_bootstrap.log
---------------------------------------------
报错:缺少C的编译器
解决办法:安装gcc编译器
[root@localhost ~]# yum install gcc
继续安装Cmake
[root@localhost cmake-2.8.4]# ./bootstrap
---------------------------------------------
CMake 2.8.4, Copyright 2000-2009 Kitware, Inc.
C compiler on this system is: cc
---------------------------------------------
Error when bootstrapping CMake:
Cannot find appropriate C++ compiler on this system.
Please specify one using environment variable CXX.
See cmake_bootstrap.log for compilers attempted.
---------------------------------------------
Log of errors: /usr/local/src/cmake-2.8.4/Bootstrap.cmk/cmake_bootstrap.log
---------------------------------------------
报错:缺少C++编译器
解决办法:安装gcc-c++编译器
[root@localhost ~]# yum install gcc-c++
再次安装
[root@localhost cmake-2.8.4]# ./bootstrap
没有报错,编译安装
[root@localhost cmake-2.8.4]# gmake
[root@localhost cmake-2.8.4]# gmake install
4.正式开始安装MySQL
添加MySQL用户和用户组
[root@localhost ~]# groupadd mysql
[root@localhost ~]# useradd -g mysql mysql
MySQL源码包从共享文件夹移至/usr并解压
[root@localhost ~]mv /mnt/hgfs/Share-CentOS/mysql-5.5.22.tar.gz /usr/mysql-5.5.22.tar.gz
[root@localhost usr]# tar xzvf mysql-5.5.22.tar.gz
[root@localhost usr]# cd mysql-5.5.22
Cmake运行
[root@localhost mysql-5.5.22]# cmake .
开始编译安装
[root@localhost mysql-5.5.22]# make && make install
进入安装目录,将程序二进制的所有权改为root,数据目录的说有权改为mysql用户,更新授权表
[root@localhost mysql-5.5.22]# cd /usr/local/mysql/
[root@localhost mysql]# chown -R root .
[root@localhost mysql]# chown -R mysql .
[root@localhost mysql]# chgrp -R mysql .
[root@localhost mysql]# scripts/mysql_install_db --user=mysql
安全启动MySQL(默认密码为空)
[root@localhost mysql]#./bin/mysqld_safe --user=mysql&
报错:
130116 22:38:46 [ERROR] /usr/local/mysql/bin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2)
130116 22:38:46 [ERROR] Can't start server: can't create PID file: No such file or directory
解决方法:
mysqld目录不存在,创建它:
#mkdir /var/run/mysqld
#cd /var/run/mysqld
创建文件mysqld.pid:
#touch mysqld.pid
#cd..
#chown -R mysql mysqld .
#cd /usr/local/mysql/
#bin/mysqld_safe --user=mysql &
nohup: ignoring input and redirecting stderr to stdout
Starting mysqld daemon with databases from /var/lib/mysql
能正常启动
#bin/mysqladmin -u root password root
又出错
[root@localhost mysql]# bin/mysqladmin -u root password root
bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
[root@localhost mysql]# bin/mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
分析:是/tmp/mysql.sock 不存在
# cd /var/lib/mysql/
由于mysql 默认的mysql.sock 是在/var/lib/mysql/mysql.sock,创建符号连接:
# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
# bin/mysql -u root
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1
Server version: 5.0.45 MySQL Community Server (GPL)
Type 'help;' or 'h' for help. Type 'c' to clear the buffer.
报错:
120908 00:16:25 mysqld_safe Logging to '/usr/local/mysql/data/CentOS.err'.
120908 00:16:26 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
解决方法:
[root@CentOS ~]# cd /usr/local/mysql/data
[root@CentOS data]# ls -l
总用量 29744
-rw-rw---- 1 mysql root 1585 9月 8 00:16 CentOS.err
-rw-rw---- 1 mysql mysql 6 9月 8 00:16 CentOS.pid
-rw-rw---- 1 mysql mysql 18874368 9月 8 00:16 ibdata1
-rw-rw---- 1 mysql mysql 5242880 9月 8 00:16 ib_logfile0
-rw-rw---- 1 mysql mysql 5242880 9月 8 00:16 ib_logfile1
drwxr-xr-x 2 mysql mysql 4096 9月 8 00:14 mysql
-rw-rw---- 1 mysql mysql 27293 9月 8 00:14 mysql-bin.000001
-rw-rw---- 1 mysql mysql 1031892 9月 8 00:14 mysql-bin.000002
-rw-rw---- 1 mysql mysql 107 9月 8 00:16 mysql-bin.000003
-rw-rw---- 1 mysql mysql 57 9月 8 00:16 mysql-bin.index
drwx------ 2 mysql mysql 4096 9月 8 00:14 performance_schema
drwxr-xr-x 2 mysql mysql 4096 9月 8 00:08 test
[root@CentOS data]# chgrp -R mysql CentOS.err
[root@CentOS data]# ls -l
总用量 29736
-rw-rw---- 1 mysql mysql 1585 9月 8 00:16 CentOS.err
-rw-rw---- 1 mysql mysql 6 9月 8 00:16 CentOS.pid
-rw-rw---- 1 mysql mysql 18874368 9月 8 00:16 ibdata1
-rw-rw---- 1 mysql mysql 5242880 9月 8 00:16 ib_logfile0
-rw-rw---- 1 mysql mysql 5242880 9月 8 00:16 ib_logfile1
drwxr-xr-x 2 mysql mysql 4096 9月 8 00:14 mysql
-rw-rw---- 1 mysql mysql 27293 9月 8 00:14 mysql-bin.000001
-rw-rw---- 1 mysql mysql 1031892 9月 8 00:14 mysql-bin.000002
-rw-rw---- 1 mysql mysql 107 9月 8 00:16 mysql-bin.000003
-rw-rw---- 1 mysql mysql 57 9月 8 00:16 mysql-bin.index
drwx------ 2 mysql mysql 4096 9月 8 00:14 performance_schema
drwxr-xr-x 2 mysql mysql 4096 9月 8 00:08 test
连接本机MySQL
[root@localhost mysql]#mysql –u root –p
提示输入password,默认为空,按Enter即可
断开连接
mysql>exit;
为root账户设置密码
[root@localhost ~]# cd /usr/local/mysql/bin
[root@localhost mysql]# ./bin/mysqladmin -u root password 123456
Enter Password:123456
设置选项文件,将配置文件拷贝到/etc下
[root@localhost mysql]# cp support-files/my-medium.cnf /etc/mysql.cnf
设置开机自启动
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysql
[root@localhost mysql]# chmod +x /etc/init.d/mysql
通过服务来启动和关闭Mysql
[root@localhost ~]# service mysql start
[root@localhost ~]# service mysql stop
5.安装设置完毕,之后使用只需启动-连接-断开-关闭,命令如下:
[root@CentOS mysql]# service mysql start
Starting MySQL.. [确定]
[root@CentOS mysql]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.22 Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.07 sec)
mysql> exit;
Bye
[root@CentOS mysql]# service mysql stop
Shutting down MySQL. [确定]
6.其它:
查看进程命令 ps –ef|grep mysqld
kill进程命令 kill –9 进程号
相关推荐
集合网上资料和自身实际安装整理的centos5.5安装mysql5.5,文档中有5.5和5.6的下载地载,如果安装5.6还需要找一点资料。
centos 6.5配置mysql5.5
CentOS 6.3 安装VMTools 本篇为大家介绍如何在CentOS 6.3中安装VMTools
Centos7安装MySQL5.5-5.7.docx
几天时间在安装数据库时,遇到了诸多问题,这里整理一下,问题基本解决,
CentOS6.3源码安装mysql5.6方法.pdf
centOS-6.3安装Mysql集群,Mysql集群易于搭建,基于内存运行,不需要共享存储,非常方便
centos6.3中编译安装mysql.5.5.30.pdf
CentOS 6.3安装(超级详细图解教程) 相当齐全
详细介绍了个人在虚拟机上安装的centos6.3系统下安装最新版本MYSQL数据库的过程和相关问题的解决。
CentOS6.3安装(超级详细图解教程)。具体软件安装步骤与方法。
Centos6.3 yum安装lamp架构
不过自从被sun收购之后,就没用集成在centos这些开源Linux系统中了,那么如果想用的话就需要自己安装了,在安装过程中肯定会用到些命令,下面通过本篇文章给大家介绍centos 7安装mysql5.5和安装 mariadb使用的命令
centos安装mysql5.5.txt
CentOS 6.3安装文档 word版
打开终端 切换到根目录 [shell@localhost ~]# su -安装Mysql5.5之前先卸载CentOS自带的Mysql5.0。 [root@localhost ~]# yum remove mysql 安装cmake 下载cmake源码包cmake-2.8.5.tar.gz [root@localhost ~]# wget ...
Centos6.3安装教您如何按照centos,已经出现的常见问题的解决
在CentOS/Red Hat Linux上安装MySQL 5.5,转载请保留文档全部信息。
CentOS6.4安装MySql5.5.27[文].pdf
centos7.0安装mysql centos7.0安装mysql centos7.0安装mysql