MySQL安装

Install on Linux

采用二进制方式安装

# 建立用户和组 (Ubuntu等系统下使用-m参数建立home dir)
shell> groupadd mysql

shell> useradd -r -g mysql -d /home/mysql -m -s /bin/bash mysql
# 解压安装
shell> cd /usr/local

shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
# 初始化数据库
shell> scripts/mysql_install_db --user=mysql

shell> chown -R root .
shell> chown -R mysql data
# Next command is optional
shell> cp support-files/my-medium.cnf /etc/my.cnf
# Next command is optional

shell> cp support-files/mysql.server /etc/init.d/mysql.server

 

# 启动和停止
shell> bin/mysqld_safe --user=mysql &
shell> bin/mysqladmin -uroot shutdown

   # 设置root密码
  shell> mysql -u root
  mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd');
  mysql> SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('newpwd');
  mysql> SET PASSWORD FOR 'root'@'::1' = PASSWORD('newpwd');
  mysql> SET PASSWORD FOR 'root'@'host_name' = PASSWORD('newpwd');

# 或者用update语句设置密码
shell> mysql -u root

mysql> UPDATE mysql.user SET Password = PASSWORD('newpwd') WHERE User = 'root';
mysql> FLUSH PRIVILEGES;

posted on 2012-01-29 10:14  wait4friend  阅读(473)  评论(0编辑  收藏  举报