Home > Database > Mysql Tutorial > body text

MySql安装(rpm)和启动配置_MySQL

WBOY
Release: 2016-06-01 13:30:37
Original
1022 people have browsed it

bitsCN.com

MySql安装(rpm)和启动配置

 

安装步骤:

1.解压MySql安装包

[root@bakdbserver mysql]# tar -xf MySQL-5.5.24-1.rhel5.x86_64.tar[root@bakdbserver mysql]# ll总计 373920-rw-r--r-- 1 root root  191242240 2012-05-28 MySQL-5.5.24-1.rhel5.x86_64.tar-rw-r--r-- 1 7161 wheel  18204697 2012-04-19 MySQL-client-5.5.24-1.rhel5.x86_64.rpm-rw-r--r-- 1 7161 wheel   3869191 2012-04-19 MySQL-devel-5.5.24-1.rhel5.x86_64.rpm-rw-r--r-- 1 7161 wheel  69218533 2012-04-19 MySQL-embedded-5.5.24-1.rhel5.x86_64.rpm-rw-r--r-- 1 7161 wheel  55049591 2012-04-19 MySQL-server-5.5.24-1.rhel5.x86_64.rpm-rw-r--r-- 1 7161 wheel   2083987 2012-04-19 MySQL-shared-5.5.24-1.rhel5.x86_64.rpm-rw-r--r-- 1 7161 wheel  42805943 2012-04-19 MySQL-test-5.5.24-1.rhel5.x86_64.rpm
Copy after login

2.创建MySql系统管理用户

[root@bakdbserver ~]# groupadd mysql[root@bakdbserver ~]# useradd -g mysql mysql[root@bakdbserver mysql]# id mysqluid=502(mysql) gid=54325(mysql) groups=54325(mysql)
Copy after login

3.安装 MySql rpm包

[root@bakdbserver mysql]# rpm -ivh "*.rpm"Preparing...                ########################################### [100%]   1:MySQL-client           ########################################### [ 17%]   2:MySQL-devel            ########################################### [ 33%]   3:MySQL-embedded         ########################################### [ 50%]   4:MySQL-server           ########################################### [ 67%]   5:MySQL-shared           ########################################### [ 83%]   6:MySQL-test             ########################################### [100%]  
Copy after login

卸载顺序:

[root@bakdbserver ~]# rpm -e MySQL-server-5.5.24-1.rhel5[root@bakdbserver ~]# rpm -e MySQL-embedded-5.5.24-1.rhel5[root@bakdbserver ~]# rpm -e MySQL-shared-5.5.24-1.rhel5[root@bakdbserver ~]# rpm -e MySQL-devel-5.5.24-1.rhel5[root@bakdbserver ~]# rpm -e MySQL-test-5.5.24-1.rhel5[root@bakdbserver ~]# rpm -e MySQL-client-5.5.24-1.rhel5--此时MySql自动安装在mysql用户下--尝试在root用户启动mysql服务[root@bakdbserver ~]# service mysql startStarting MySQL..[确定][root@bakdbserver ~]# ps -ef|grep mysqlroot     17075     1  0 15:35 pts/1    00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/bakdbserver.pidmysql    17153 17075  0 15:35 pts/1    00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/bakdbserver.err --pid-file=/var/lib/mysql/bakdbserver.pidroot     17178 12211  0 15:35 pts/1    00:00:00 grep mysql
Copy after login

mysql安装软件在/usr/share/mysql目录下

Mysql数据库创建在/var/lib/mysql目录下

4.修改安装目录权限

说明:

为了安全地管理MySQL,应使用系统的mysql专有用户进行MySQL的日常管理,为了使mysql用户有读写安装目录的权限,应修MySQL安装目录的权限。

[root@bakdbserver mysql]# cd /usr/share/mysql[root@bakdbserver share]# chown -R mysql:mysql .[root@bakdbserver mysql]# ll总计 1324-rwxr-xr-x 1 mysql mysql   1153 2012-04-19 binary-configuredrwxr-xr-x 2 mysql mysql   4096 08-23 11:39 charsets-rwxr-xr-x 1 mysql mysql   4528 2012-04-19 config.huge.ini...--由于MySQL数据库目录已经是mysql用户权限,故不用修改[root@bakdbserver mysql]# cd /var/lib/mysql[root@bakdbserver mysql]# ll总计 28752drwx--x--x 2 mysql mysql     4096 08-23 09:17 mysqldrwx------ 2 mysql mysql     4096 08-23 09:17 performance_schema-rw-r--r-- 1 mysql mysql      616 08-23 11:39 RPM_UPGRADE_HISTORY-rw-r--r-- 1 mysql mysql      495 08-23 11:39 RPM_UPGRADE_MARKER-LASTdrwxr-xr-x 2 mysql mysql     4096 08-23 09:17 test...
Copy after login

5.启动MySQL服务器

处于安全方面的原因,应避免以Linux根用户身份运行服务器,应以mysql用户身份启动服务器。

[root@bakdbserver mysql]# ./mysql.server start --user=mysqlStarting MySQL..[确定]或是[root@bakdbserver mysql]# /usr/bin/mysqld_safe --user=mysql &
Copy after login

要想在系统启动时自动以给定的用户身份启动服务器,可在服务器数据目录下的/etc/my.cnf选项文件的[mysqld]组中,通过增加用户选项来指定用户名

--如果没有/etc/my.cnf文件,可以手动创建[root@bakdbserver ~]# vi /etc/my.cnf[mysqld]user=mysql[root@bakdbserver ~]# chown mysql:mysql /etc/my.cnf
Copy after login

6.为mysql添加环境变量

为方便管理和使用,在系统mysql用户下添加环境变量

[mysql@bakdbserver ~]$ vi .bash_profilePATH=$PATH:$HOME/binexport PATHexport LANG=zh_CNexport DATADIR=/var/lib/mysqlexport BASEDIR=/usrexport MYSQL_HOME=$BASEDIR/share/mysql
Copy after login

7.修改mysql数据库root用户密码

安装完成后root密码默认为空,为了安全必需修改root初始密码

[mysql@bakdbserver ~]$ mysqladmin -uroot -p password rootEnter password:
Copy after login

 

 

bitsCN.com
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template