1.先检查系统有没有安装mysql
[[email protected] opt]# rpm -qa|grep mysql
# 我们看到,并没有安装mysql,但是有一个mysql的libs开发包插件,他是干什么的呢?
# 解释:由于CentOS6.4系统自带就有postfix服务,而这个mysql-libs呢就是支持这个postfix服务的,如果我们不使用到postfix,那就卸载掉吧,而且每一个mysql-server安装的时候,后自带安装上这个mysql-libs。
#删除mysl-;ib,系统就干净了
[[email protected] opt]# yum remove mysql-libs
2 下载mysql-5.6.21.tar.gz, 我们准备安装在/user/local 数据放在/uer/local/data 下
[[email protected] ~]# groupadd mysql #创建用户组mysql [[email protected] ~]# useradd -g mysql mysql -s /bin/false #创建用户mysql 不能远程登录 [[email protected] ~]# mkdir /usr/local/mysql [[email protected] ~]# mkdir /usr/local/mysql/data [[email protected] ~]# cp mysql-5.6.21.tar.gz /usr/local[[email protected] ~]# cd /usr/local/[[email protected] local]# tar -xzvf mysql-5.6.21.tar.gz #解压#安装cmake编译环境和依赖包[[email protected] local]# yum -y install make gcc-c++ cmake openssl openssl-devel bison-devel ncurses ncurses-devel wget perl perl-devel
3.开始编译安装mysql
cmake --no-warn-unused-cli -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_unicode_ci -DENABLE_PROFILING=1 -DENABLED_LOCAL_INFILE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 [[email protected] mysql-5.6.21]# make && make install #等待较长时间 [[email protected] mysql-5.6.21]# make clean #安装完后 清理一下临时文件
4.配置mysql
[[email protected] local]# chown -R mysql:mysql /usr/local/mysql #修改mysql目录的所属用户权限
#初始化脚本
[[email protected] data]# cd mysql/data
[[email protected] data]# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
#设置mysql服务开机自动启动[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysql [[email protected] mysql]# chkconfig mysql on [[email protected] mysql]# service mysql start Starting MySQL. SUCCESS! [[email protected] mysql]#
[[email protected] mysql]# vim /etc/profile #修改环境变量 使得可以使用mysql命令 PATH添加/usr/local/mysql/bin [[email protected] mysql]# source /etc/profile #使得配置文件生效 [[email protected] mysql]# mysql -uroot #使用root(这时没有密码)登录 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.21 Source distribution Copyright (c) 2000, 2014, 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>
mysql> SET PASSWORD = PASSWORD(‘123456‘); #修改root用户的密码 mysql> GRANT ALL PRIVILEGES ON *.* TO [email protected]‘%‘ IDENTIFIED BY ‘password‘ WITH GRANT OPTION; #root用户使用密码‘passwprd‘远程登录
时间: 2024-10-10 20:36:26