首页 > 代码库 > linux mysql rpm 安装

linux mysql rpm 安装

#将rpm包上传到/root/work目录(也可以是其他目录)
MySQL-server-5.6.29-1.linux_glibc2.5.x86_64.rpm
MySQL-client-5.6.29-1.linux_glibc2.5.x86_64.rpm

#查看之前是否安装过mysql
rpm -qa | grep -i mysql
#如果安装过,执行这行代码,删除之前安装过的mysql
rpm -ev --nodeps mysql-libs-5.1.71-1.el6.x86_64

#增加用户组mysql
groupadd mysql
#增加用户mysql,加入mysql用户组
useradd -r -g mysql mysql

#安装server
rpm -ivh MySQL-server-5.6.29-1.linux_glibc2.5.x86_64.rpm
#安装client
rpm -ivh MySQL-client-5.6.29-1.linux_glibc2.5.x86_64.rpm

====mysql5.6安装后所在的目录====================================================================
Directory Contents of Directory
/usr/bin Client programs and scripts
/usr/sbin The mysqld server
/var/lib/mysql Log files, databases
/usr/share/info MySQL manual in Info format
/usr/share/man Unix manual pages
/usr/include/mysql Include (header) files
/usr/lib/mysql Libraries
/usr/share/mysql Miscellaneous support files, including error messages, character set files, sample configuration files, SQL for database installation
/usr/share/sql-bench Benchmarks
==========================================================================================
#修改my.cnf,默认在/usr/my.cnf
vim /usr/my.cnf
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
character_set_server=utf8
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

#将mysqld加入系统服务,并随机启动
cp /usr/share/mysql/mysql.server /etc/init.d/mysqld

#下面两句不需要!!
#chkconfig --add mysqld
#chkconfig mysqld on

#启动mysqld
service mysqld start

#获取mysql安装时root用户的随机密码
vim /root/.mysql_secret

#必须要修改root用户的密码才可以使用mysql,否则只能连接不能操作
mysqladmin -u root -p password root

#连接进入mysql
mysql -u root -p
root

#查看mysql的安装运行路径
ps -ef|grep mysql

linux mysql rpm 安装