install mysql on linux

install mysql on linux
(1)下载mysql二进制分发包到工作目录

(2)创建mysql 用户
shell> groupadd mysql
shell> useradd -g mysql mysql

(3)解压缩
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz

(4)将工作目录链接到/usr/local/mysql
shell> cd /usr/localshell> ln -s full-path-to-mysql-VERSION-OS mysql

(5)安装数据库
shell> cd mysql
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root  .
shell> chown -R mysql data
shell> chgrp -R mysql .

*此时可以手动启动数据库:
shell> bin/mysqld_safe --user=mysql &

(6)设置mysql自动启动
将/usr/local/mysql/support-files/mysql.server 复制到/etc/init.d/mysql
shell> cp mysql.server /etc/init.d/mysql
shell> chmod +x /etc/init.d/mysql


在ubuntu server中添加为系统服务:
sudo update-rc.d mysql defaults
如需删除服务:
sudo update-rc.d mysql remove 

在RHEL4中:
shell> chkconfig --add mysql

(7)配置mysql
添加my.cnf到/etc

启动数据库更改root密码:
cd /usr/local/mysql/bin./mysql -u root -p
mysql>GRANT ALL PRIVILEGES ON *.* TO  root@ localhost IDENTIFIED BY "password";

或者启动远程访问:
mysql>GRANT ALL PRIVILEGES ON *.* TO  root@ "%" IDENTIFIED BY "password";

你可能感兴趣的:(install mysql on linux)