redhat mysql32 安装_Linux 安装 mysql (5.5.32)(redhat)(mysql已经安装,冲突)

mysql 下载地址:http://dev.mysql.com/downloads/mysql/5.1.html#downloads

cmake 下载地址:http://www.cmake.org/cmake/resources/software.html

1.假设已经有mysql-5.5.10.tar.gz以及cmake-2.8.4.tar.gz两个源文件

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

[root@ rhel5 local]#tar -zxv -f cmake-2.8.4.tar.gz[root@ rhel5 local]#cd cmake-2.8.4

[root@ rhel5 cmake-2.8.4]

#

./configure

//有的版本是运行./bootstrap make make install[root@ rhel5 cmake-2.8.4]#make[root@ rhel5 cmake-2.8.4]#make install

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

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

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

[root@ rhel5~]groupadd mysql //这里我提示 groupadd:mysql 组已存在

[root@ rhel5~]useradd -r -g mysql mysql //useradd:用户 mysql 已存在

(4)安装mysql

0818b9ca8b590ca3270a3433284dd417.png

[root@ rhel5 local]#tar -zxv -f mysql-5.5.10.tar.gz //这里发现执行不了,后来换了参数OK.

[root@localhost local]# tar xvf MySQL-5.5.32-1.rhel5.i386.rpm-bundle.tar  MySQL-shared-5.5.32-1.rhel5.i386.rpm MySQL-embedded-5.5.32-1.rhel5.i386.rpm MySQL-devel-5.5.32-1.rhel5.i386.rpm MySQL-test-5.5.32-1.rhel5.i386.rpm MySQL-server-5.5.32-1.rhel5.i386.rpm MySQL-shared-compat-5.5.32-1.rhel5.i386.rpm MySQL-client-5.5.32-1.rhel5.i386.rpm [root@localhost local]#

[root@localhost local]# chmod 755 MySQL-server-5.5.32-1.rhel5.i386.rpm  [root@localhost local]# rpm -ivh MySQL-server-5.5.32-1.rhel5.i386.rpm  error: Failed dependencies:         MySQL conflicts with mysql-5.0.77-3.el5.i386 //版本冲突,已经装了一个mysql5.0.77         MySQL-server conflicts with mysql-server-5.0.77-3.el5.i386 [root@localhost local]# rpm -qa | grep mysql libdbi-dbd-mysql-0.8.1a-1.2.2 mysql-5.0.77-3.el5 mysql-connector-odbc-3.51.26r1127-1.el5 mysql-server-5.0.77-3.el5

[root@localhost ~]# /etc/rc.d/init.d/mysqld start 初始化 MySQL 数据库: Installing MySQL system tables... 130709 12:03:39 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295 130709 12:03:39 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295 OK Filling help tables... 130709 12:03:42 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295 130709 12:03:42 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295 OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/bin/mysqladmin -u root password 'new-password' /usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password' Alternatively you can run: /usr/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default.  This is strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with: cd /usr ; /usr/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd mysql-test ; perl mysql-test-run.pl Please report any problems with the /usr/bin/mysqlbug script! The latest information about MySQL is available on the web at http://www.mysql.com Support MySQL by buying support/licenses at http://shop.mysql.com                                                            [确定] 启动 MySQL:                                               [确定] [root@localhost ~]#  [root@localhost ~]# mysqladmin version mysqladmin  Ver 8.41 Distrib 5.0.77, for redhat-linux-gnu on i386 Copyright (C) 2000-2006 MySQL AB This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL license Server version          5.0.77 Protocol version        10 Connection              Localhost via UNIX socket UNIX socket             /var/lib/mysql/mysql.sock Uptime:                 17 sec Threads: 1  Questions: 2  Slow queries: 0  Opens: 12  Flush tables: 1  Open tables: 6  Queries per second avg: 0.118 [root@localhost ~]# mysql Welcome to the MySQL monitor.  Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.0.77 Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> show databases; +--------------------+ | Database           | +--------------------+ | information_schema |  | mysql              |  | test               |  +--------------------+ 3 rows in set (0.00 sec) mysql>  //悲催,啥时候装的mysql俺都不知道,稍后卸载再装5.5(未完待续)

[root@ rhel5 local]#cd mysql-5.5.10[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

0818b9ca8b590ca3270a3433284dd417.png

参数说明:

-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)设置环境变量

0818b9ca8b590ca3270a3433284dd417.png

[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

0818b9ca8b590ca3270a3433284dd417.png

(5)手动启动mysql

0818b9ca8b590ca3270a3433284dd417.png

[root@ rhel5~]#cd /usr/local/mysql

[root@ rhel5 mysql]#./bin/mysqld_safe --user=mysql &   //启动MySQL,但不能停止

启动日志写在此文件下:/usr/local/mysql/data/localhost.err

关闭MySQL服务

[root@ rhel5 mysql]#mysqladmin -u root -p shutdown  //这里MySQL的root用户还没有配置密码,所以为空值。需要输入密码时,直接点回车键即可。

0818b9ca8b590ca3270a3433284dd417.png

(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用户的密码以及打开远程连接

0818b9ca8b590ca3270a3433284dd417.png

[root@ rhel5~]#mysql -u root mysql

mysql>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

0818b9ca8b590ca3270a3433284dd417.png

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

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值