首页 > 数据库 > mysql教程 > MySQL安装_MySQL

MySQL安装_MySQL

WBOY
发布: 2016-05-27 14:29:42
原创
1100 人浏览过

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
相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板