博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
LINUX下编译安装最新版本mysql
阅读量:6652 次
发布时间:2019-06-25

本文共 3378 字,大约阅读时间需要 11 分钟。

通过参考其他文章

1.下载安装mysql-5.5.30.tar.gz与cmake.2.8.11.2.tar.gz

(1)先安装cmake(mysql5.5以后是通过cmake来编译的)

[root@ rhel5 local]#tar -zxv -f cmake-2.8.11.2.tar.gz[root@ rhel5 local]#cd cmake-2.8.11.2[root@ rhel5 cmake-2.8.4]#./configure[root@ rhel5 cmake-2.8.4]#make[root@ rhel5 cmake-2.8.4]#make install

在configure cmake过程中可能会出现Cannot find appropriate C++ compiler on this system这个错误提示,说明缺少c++编译器,因此安装 yum -y install gcc-c++

(2)创建mysql的安装目录及数据库存放目录

[root@ rhel5~]#mkdir -p /usr/local/mysql                 //安装mysql [root@ rhel5~]#mkdir -p /usr/local/mysql/data            //存放数据库

(3)创建mysql用户及用户组

[root@ rhel5~]groupadd mysql[root@ rhel5~]useradd -r -g mysql mysql

(4)安装mysql

[root@ rhel5 local]#tar -zxv -f mysql-5.5.30.tar.gz[root@ rhel5 local]#cd mysql-5.5.30[root@ rhel5 mysql-5.5.10]#cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/usr/local/mysql/data-DDEFAULT_CHARSET=utf8(可有可无)-DDEFAULT_COLLATION=utf8_general_ci  (可有可无)
-DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1[root@ rhel5 mysql-5.5.10]#make[root@ rhel5 mysql-5.5.10]#make install

参数说明:

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql //安装目录

-DINSTALL_DATADIR=/usr/local/mysql/data //数据库存放目录

-DDEFAULT_CHARSET=utf8 //使用utf8字符

-DDEFAULT_COLLATION=utf8_general_ci //校验字符

-DEXTRA_CHARSETS=all //安装所有扩展字符集

-DENABLED_LOCAL_INFILE=1 //允许从本地导入数据

 

注意事项:

重新编译时,需要清除旧的对象文件和缓存信息。

# make clean

# rm -f CMakeCache.txt

# rm -rf /etc/my.cnf

2.配置

(1)设置目录权限

[root@ rhel5~]# cd /usr/local/mysql[root@ rhel5 mysql]# chown -R root:mysql . //把当前目录中所有文件的所有者所有者设为root,所属组为mysql[root@ rhel5 mysql]# chown -R mysql:mysql data

(2)

[root@ rhel5 mysql]# cp support-files/my-medium.cnf /etc/my.cnf //将mysql的启动服务添加到系统服务中

(3)创建系统数据库的表

[root@ rhel5 mysql]# cd /usr/local/mysql[root@ rhel5 mysql]# scripts/mysql_install_db --user=mysql //这个是必须的,这是初始化数据库,否则会提示很多警告和错误

(4)设置环境变量

[root@ rhel5~]# vi /root/.bash_profile在PATH=$PATH:$HOME/bin添加参数为:PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib[root@ rhel5~]#source /root/.bash_profile

(5)手动启动mysql

[root@ rhel5~]# cd /usr/local/mysql[root@ rhel5 mysql]# ./bin/mysqld_safe --user=mysql &   //启动MySQL,但不能停止启动日志写在此文件下:/usr/local/mysql/data/localhost.err (这里记录了mysql所有启动时提示的各种信息,包括错误信息)关闭MySQL服务[root@ rhel5 mysql]# mysqladmin -u root -p shutdown  //这里MySQL的root用户还没有配置密码,所以为空值。需要输入密码时,直接点回车键即可。

(6)另一种简单的启动mysql的方法(mysql已经被添加到系统服务中)

[root@ rhel5~]# service mysql.server start  [root@ rhel5~]# service mysql.server stop[root@ rhel5~]# service mysql.server restart

如果上述命令出现:mysql.server 未识别的服务

则可能mysql还没添加到系统服务中,下面用另一种方法添加:

[root@ rhel5 mysql]# cp support-files/mysql.server  /etc/init.d/mysql //将mysql的启动服务添加到系统服务中

注意:主要是将mysql.server拷贝到/etc/init.d中,命名为mysql。在有的系统中,mysql.server在/usr/local/mysql/share/mysql/mysql.server中,而本系统中,mysql.server在/usr/local/mysql/support-files/mysql.server中。

然后再用#service mysql start 来启动mysql即可。

(7)修改MySQL的root用户的密码以及打开远程连接

[root@ rhel5~]# mysql -u root mysqlmysql>use mysql;mysql>desc user;mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root";  //为root添加远程连接的能力。mysql>update user set Password = password('xxxxxx') where User='root';mysql>select Host,User,Password  from user where User='root'; mysql>flush privileges;mysql>exit重新登录:mysql -u root -p若还不能进行远程连接,则关闭防火墙[root@ rhel5~]# /etc/rc.d/init.d/iptables stop

注:如果不能远程连接,出现错误mysql error number 1130,则加入下面语句试试:

mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '******' WITH GRANT OPTION;

 

转载地址:http://qkjto.baihongyu.com/

你可能感兴趣的文章
MFC 自绘按钮 消息响应
查看>>
【C#小知识】C#中一些易混淆概念总结(八)---------解析接口 分类: ...
查看>>
数值类型的保留指定小数位
查看>>
mysql如何添加用户
查看>>
版本管理(转)
查看>>
C# checkboxlist的使用
查看>>
Java 学习笔记 五 -- Jedis
查看>>
02-CSS基础与进阶-day9_2018-09-12-21-02-40
查看>>
MyEclipse编辑xml文件没有提示
查看>>
Activity
查看>>
跨浏览器的事件对象——EventUtil
查看>>
自定义Toast
查看>>
CentOS 报no acceptable C compiler found in $PATH的解决办法
查看>>
Objecttive-C各种问题
查看>>
Python中的"克隆" - 深浅Copy
查看>>
抛出异常
查看>>
新的启程~
查看>>
对于一个段错误(核心已转储)问题的解答,错误的英文翻译是segment fault(core dumped)...
查看>>
BZOJ3862Little Devil I——树链剖分+线段树
查看>>
linux 一个读写锁的使用异常导致的故障
查看>>