Home > Database > Mysql Tutorial > body text

Linux下MySQL Install

WBOY
Release: 2016-06-07 16:53:16
Original
1162 people have browsed it

1. 从http://www.mysql.com 下载的Mysql安装包 花开2.将mysql的压缩包复制到/usr/local/ 目录# cp mysql-standard-5.0.15-linux

1. 从 下载的Mysql安装包  花开

2.将mysql的压缩包复制到/usr/local/ 目录

# cp mysql-standard-5.0.15-linux-gnu-i686-glibc23.tar.gz /usr/local

3. 解压缩到/usr/ocal/下并改名为mysql,并为了节省空间,删除mysql安装包

# tar xzvf mysql-standard-5.0.15-linux-gnu-i686-glibc23.tar.gz

# mv mysql-standard-5.0.15-linux-gnu-i686-glibc23 mysql

# rm mysql-standard-5.0.15-linux-gnu-i686-glibc23

4.建立mysql组,建立mysql用户并且加入到mysql组中

# groupadd mysql

# useradd mysql -g mysql

5. 覆盖/etc/my.cnf

# cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf

6. 进入mysql目录初试化表并且规定用mysql用户来访问。初始化表以后就开始给mysql和root用户设定访问权限

# cd /usr/local/mysql

# ./scripts/mysql_install_db --user=mysql

7. 设定root能访问/usr/local/mysql

# chown -R root .

8. 设定mysql用户能访问/usr/local/mysql/data ,里面存的是mysql的数据库文件.这个目录是在/etc/my.cnf中有配置,,在mysql_install_db时产生

# chown -R mysql data

9. 设定mysql用户能访问/usr/local/mysql/data/mysql下的所有文件

# chown -R mysql data/.

10.设定mysql组能够访问/usr/local/mysql

# chgrp -R mysql .

11. 运行mysql,如果没有问题的话,应该会出现类似这样的提示:

[1] 42264

Starting mysqld daemon with databases from /usr/local/mysql/var

# /usr/local/mysql/bin/mysqld_safe --user=mysql &

如果出现 mysql ended这样的语句,表示Mysql没有正常启动,你可以到log中查找问题,Log文件的通常在/etc/my.cnf中配置。大多数问题是权限设置不正确引起的。

12. 用如下命令修改MYSQL密

# /usr/local/mysql/bin/mysqladmin -u root password yourpassword

13. copy编译目录的一个脚本,设置使mysql每次启动都能自动运行

# cp support-files/mysql.server /etc/rc.d/init.d/mysqld

# chmod 700 /etc/init.d/mysqld

# chkconfig --add mysqld

# chkconfig --level 345 mysqld on

14. 启动mysqld服务 拥抱

# service mysqld start

linux

Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!