>  기사  >  데이터 베이스  >  MySQL安装_MySQL

MySQL安装_MySQL

WBOY
WBOY원래의
2016-05-27 14:29:421060검색

bitsCN.com

Install on Linux

采用二进制方式安装

# 建立用户和组<strong class="userinput"><code><br /></code></strong>shell> <strong class="userinput"><code>groupadd mysql</code></strong><br />shell> <strong class="userinput"><code>useradd -r -g mysql -d /home/mysql -s /bin/bash mysql<br /># 解压安装<br /></code></strong>shell> <strong class="userinput"><code>cd /usr/local</code></strong><br />shell> <strong class="userinput"><code>tar zxvf <em class="replaceable"><code>/path/to/mysql-VERSION-OS</code></em>.tar.gz</code></strong><br />shell> <strong class="userinput"><code>ln -s <em class="replaceable"><code>full-path-to-mysql-VERSION-OS</code></em> mysql</code></strong><br />shell> <strong class="userinput"><code>cd mysql</code></strong><br />shell> <strong class="userinput"><code>chown -R mysql .</code></strong><br />shell> <strong class="userinput"><code>chgrp -R mysql .<br /># 初始化数据库<br /></code></strong>shell> <strong class="userinput"><code>scripts/mysql_install_db --user=mysql</code></strong><br />shell> <strong class="userinput"><code>chown -R root .</code></strong><br />shell> <strong class="userinput"><code>chown -R mysql data</code></strong><br /># Next command is optional<br />shell> <strong class="userinput"><code>cp support-files/my-medium.cnf /etc/my.cnf<br /></code></strong># Next command is optional<br />shell> <strong class="userinput"><code>cp support-files/mysql.server /etc/init.d/mysql.server</code></strong>

 

<strong class="userinput"><code># 启动和停止<br /></code></strong>shell> <strong class="userinput"><code>bin/mysqld_safe --user=mysql &<br /></code></strong>shell> <strong class="userinput"><code>bin/mysqladmin -uroot shutdown</code></strong>

   # 设置root密码
  shell> mysql -u root<br>  mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('<em class="replaceable"><code>newpwd');
  mysql> SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('<em class="replaceable"><code>newpwd');
  mysql> SET PASSWORD FOR 'root'@'::1' = PASSWORD('<em class="replaceable"><code>newpwd');
  mysql> SET PASSWORD FOR 'root'@'host_name' = PASSWORD('newpwd');

<strong class="userinput"><code># 或者用update语句设置密码<br /></code></strong>shell> <strong class="userinput"><code>mysql -u root</code></strong><br />mysql> <strong class="userinput"><code>UPDATE mysql.user SET Password = PASSWORD('<em class="replaceable"><code>newpwd</code></em>')</code></strong> <strong class="userinput"><code>WHERE User = 'root';</code></strong><br />mysql> <strong class="userinput"><code>FLUSH PRIVILEGES;</code></strong>
bitsCN.com
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.