标签:
1、配置本地yum源
1 vim /etc/yum.repos.d/rhel-source.repo 2 [rhel-source] 3 name=Red Hat Enterprise Linux $releasever - $basearch - Source 4 baseurl=file:///mnt 5 enabled=1 6 gpgcheck=0
2、清除yum缓存
yum clean all
3、更新yum源
yum update all
yum安装 yum install 软件名
卸载 yum remove 软件名
1、卸载rpm mysql软件
2、新建用户
# cat /etc/passwd | grep mysql mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash # userdel mysql //删除rpm的用户 useradd -M -s /sbin/nologin mysql groupadd mysql //添加用户组 useradd -r -g mysql mysql
3、解压缩
4、配置安装参数
yum -y install cmake
5.7版本以后 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql/ -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=0 -DWITH_MEMORY_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DDEFAULT_CHARSET=utf8
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql #安装路径 -DMYSQL_DATADIR=/data/mysql/ #数据文件存放位置 -DSYSCONFDIR=/etc #my.cnf路径 -DWITH_MYISAM_STORAGE_ENGINE=1 #支持MyIASM引擎 -DWITH_INNOBASE_STORAGE_ENGINE=0 #支持InnoDB引擎 -DWITH_MEMORY_STORAGE_ENGINE=1 #支持InnoDB引擎 -DWITH_READLINE=1 #快捷键功能(我没用过) -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock #连接数据库socket路径 -DMYSQL_TCP_PORT=3306 #端口 -DENABLED_LOCAL_INFILE=1 #允许从本地导入数据 -DWITH_PARTITION_STORAGE_ENGINE=1 #安装支持数据库分区 -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk #安装需要的字符集 -DDEFAULT_CHARSET=utf8 #默认字符 -DDEFAULT_COLLATION=utf8_general_ci #默认字符集-DMYSQL_USER=mysql
错误1:error: No curses/termcap 解决办法: # yum install ncurses-devel
5、make 编译
错误2:“../depcomp: line 571: exec: g++: not found” 解决办法:yum install gcc*
6、make install
错误3: ../include/my_global.h:982: 错误:对 C++ 内建类型 ‘bool’ 的重声明 make[2]: *** [my_new.o] 错误 1 make[2]: Leaving directory `/usr/src/mysql-5.1.49/mysys‘ make[1]: *** [all-recursive] 错误 1 make[1]: Leaving directory `/usr/src/mysql-5.1.49‘ make: *** [all] 错误 2 解决办法: ./configure加入参数 “--with-unix-socket-path=/tmp/mysql.sock”//指定套接字路径
7、生成mysql的配置文件
# cp support-files/my-medium.cnf /etc/my.cnf
更改配置文件
[root@pythonS1 ~]# vim /etc/my.cnf [client] default-character-set=utf8 port=3306 socket=/data/mysql/mysql.sock [mysqld] character-set-server=utf8 pid-file = /data/mysql/mysql.pid log-error=/var/log/mysqld.log datadir=/data/mysql basedir=/usr/local/mysql socket=/data/mysql/mysql.sock user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/mysql/mysql/mysqld.pid
8、初始化mysql数据库
/usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql --user=mysql
9、修改属主、属组
chown mysql.mysql -R /data/mysql chmod +x /usr/local/mysql chown -R :mysql /var/lib/mysql/
10、生成mysql控制服务
# cp support-files/mysql.server /etc/rc.d/init.d/mysqld(以后可以使用/etc/init.d/mysqld restart 命令) # chmod a+x /etc/rc.d/init.d/mysqld # chkconfig --add /etc/rc.d/init.d/mysqld //添加为系统服务,目的是为了开机自动启动(以后可以使用chkconfig mysqld on命令)
11、启动mysqld服务
# /etc/init.d/mysqld start netstat -antp | grep mysqld
12、建立mysql命令的软链接
环境变量PATH echo $ PATH # ln -s /usr/local/mysql/bin/* /usr/local/bin/
13、保证其他软件(apache、nginx、php)和mysql可以协同工作
# ln -s /usr/local/mysql/lib/mysql/* /usr/local/lib # ln -s /usr/local/mysql/include/mysql/* /usr/local/include/
14.修改密码:
A.进入配置文件:/etc/my.cnf [mysqld] skip-grant-tables 加入这句 B.
/usr/local/mysql/bin/mysql进入 UPDATE user SET password=PASSWORD("newpassword") WHERE user=‘root‘; FLUSH PRIVILEGES; 验证密码是否成功: select user,host,password from mysql.user; 是否有md5值
create database db_test; C.创建一个新用户用于管理 db_test 数据库 insert into mysql.user(Host,User,Password) values("localhost","admin",password("newpassword")); flush privileges; D.赋予权限 grant all privileges on db_test.* to db_test@localhost identified by ‘newpassword‘;
标签:
原文地址:http://www.cnblogs.com/renfanzi/p/5613431.html